Fix extension update badge again

This commit is contained in:
arkon 2020-04-19 23:10:28 -04:00
parent 6675de1a26
commit cd25e1283a

View File

@ -13,7 +13,6 @@ import com.bluelinelabs.conductor.RouterTransaction
import eu.kanade.tachiyomi.Migrations import eu.kanade.tachiyomi.Migrations
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.notification.NotificationReceiver import eu.kanade.tachiyomi.data.notification.NotificationReceiver
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
import eu.kanade.tachiyomi.databinding.MainActivityBinding import eu.kanade.tachiyomi.databinding.MainActivityBinding
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
@ -154,8 +153,9 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
} }
} }
preferences.extensionUpdatesCount().asImmediateFlow() setExtensionsBadge()
.onEach { setExtensionsBadge(it) } preferences.extensionUpdatesCount().asFlow()
.onEach { setExtensionsBadge() }
.launchInUI() .launchInUI()
} }
@ -170,7 +170,8 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
getExtensionUpdates() getExtensionUpdates()
} }
private fun setExtensionsBadge(updates: Int) { private fun setExtensionsBadge() {
val updates = preferences.extensionUpdatesCount().get()
if (updates > 0) { if (updates > 0) {
binding.bottomNav.getOrCreateBadge(R.id.nav_more).number = updates binding.bottomNav.getOrCreateBadge(R.id.nav_more).number = updates
} else { } else {