Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: notification bell shown even though notifications disabled #6133

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
}

var isIgnorable = PreferenceHelper.isChannelNotificationIgnorable(channelId)
setIconResource(if (isIgnorable) R.drawable.ic_bell else R.drawable.ic_notification)
setIconResource(iconResource(isIgnorable))

setOnClickListener {
isIgnorable = !isIgnorable
PreferenceHelper.toggleIgnorableNotificationChannel(channelId)
setIconResource(if (isIgnorable) R.drawable.ic_bell else R.drawable.ic_notification)
setIconResource(iconResource(isIgnorable))
}
}

private fun iconResource(isIgnorable: Boolean) =

Check failure on line 25 in app/src/main/java/com/github/libretube/ui/extensions/SetupNotificationBell.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 First line of body expression fits on same line as function signature Raw Output: app/src/main/java/com/github/libretube/ui/extensions/SetupNotificationBell.kt:25:49: error: First line of body expression fits on same line as function signature (standard:function-signature)
if (isIgnorable) R.drawable.ic_bell else R.drawable.ic_notification

Check failure on line 26 in app/src/main/java/com/github/libretube/ui/extensions/SetupNotificationBell.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 File must end with a newline (\n) Raw Output: app/src/main/java/com/github/libretube/ui/extensions/SetupNotificationBell.kt:26:71: error: File must end with a newline (\n) (standard:final-newline)
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import androidx.core.view.isVisible
import com.github.libretube.R
import com.github.libretube.api.SubscriptionHelper
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.helpers.PreferenceHelper
import com.google.android.material.button.MaterialButton
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext

fun TextView.setupSubscriptionButton(
Expand Down Expand Up @@ -38,19 +39,26 @@
}

notificationBell?.setupNotificationBell(channelId)
this.setOnClickListener {

setOnClickListener {
if (subscribed == true) {
SubscriptionHelper.handleUnsubscribe(context, channelId, channelName) {
this.text = context.getString(R.string.subscribe)
text = context.getString(R.string.subscribe)
notificationBell?.isGone = true

subscribed = false
onIsSubscribedChange(false)
}
} else {
runBlocking {
SubscriptionHelper.subscribe(channelId)
CoroutineScope(Dispatchers.Main).launch {
withContext(Dispatchers.IO) {
SubscriptionHelper.subscribe(channelId)
}

text = context.getString(R.string.unsubscribe)
notificationBell?.isVisible = true
notificationBell?.isVisible = PreferenceHelper

Check failure on line 59 in app/src/main/java/com/github/libretube/ui/extensions/SetupSubscriptionButton.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 A multiline expression should start on a new line Raw Output: app/src/main/java/com/github/libretube/ui/extensions/SetupSubscriptionButton.kt:59:47: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
.getBoolean(PreferenceKeys.NOTIFICATION_ENABLED, true)

subscribed = true
onIsSubscribedChange(true)
}
Expand Down
Loading