mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 13:50:30 +05:30
fix: notification bell shown even though notifications disabled
This commit is contained in:
parent
a692f8d8f1
commit
cf4363d703
@ -13,11 +13,14 @@ fun MaterialButton.setupNotificationBell(channelId: String) {
|
||||
}
|
||||
|
||||
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) =
|
||||
if (isIgnorable) R.drawable.ic_bell else R.drawable.ic_notification
|
@ -5,11 +5,12 @@ import androidx.core.view.isGone
|
||||
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(
|
||||
@ -38,19 +39,26 @@ fun TextView.setupSubscriptionButton(
|
||||
}
|
||||
|
||||
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
|
||||
.getBoolean(PreferenceKeys.NOTIFICATION_ENABLED, true)
|
||||
|
||||
subscribed = true
|
||||
onIsSubscribedChange(true)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user