|
@@ -12,7 +12,6 @@ import com.bluelinelabs.conductor.RouterTransaction
|
|
|
import eu.kanade.tachiyomi.Migrations
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
|
|
-import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
|
import eu.kanade.tachiyomi.databinding.MainActivityBinding
|
|
|
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
|
|
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
|
@@ -30,10 +29,12 @@ import eu.kanade.tachiyomi.ui.recent.history.HistoryController
|
|
|
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
|
|
import eu.kanade.tachiyomi.ui.source.SourceController
|
|
|
import eu.kanade.tachiyomi.ui.source.global_search.GlobalSearchController
|
|
|
+import eu.kanade.tachiyomi.util.lang.launchInUI
|
|
|
import java.util.Date
|
|
|
import java.util.concurrent.TimeUnit
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
+import kotlinx.coroutines.flow.onEach
|
|
|
import kotlinx.coroutines.launch
|
|
|
import timber.log.Timber
|
|
|
|
|
@@ -141,10 +142,11 @@ class MainActivity : BaseActivity() {
|
|
|
ChangelogDialogController().showDialog(router)
|
|
|
}
|
|
|
}
|
|
|
- preferences.extensionUpdatesCount().asObservable().subscribe {
|
|
|
- setExtensionsBadge()
|
|
|
- }
|
|
|
+
|
|
|
setExtensionsBadge()
|
|
|
+ preferences.extensionUpdatesCount().asFlow()
|
|
|
+ .onEach { setExtensionsBadge() }
|
|
|
+ .launchInUI()
|
|
|
}
|
|
|
|
|
|
override fun onNewIntent(intent: Intent) {
|
|
@@ -159,7 +161,7 @@ class MainActivity : BaseActivity() {
|
|
|
}
|
|
|
|
|
|
private fun setExtensionsBadge() {
|
|
|
- val updates = preferences.extensionUpdatesCount().getOrDefault()
|
|
|
+ val updates = preferences.extensionUpdatesCount().get()
|
|
|
if (updates > 0) {
|
|
|
binding.bottomNav.getOrCreateBadge(R.id.nav_more).number = updates
|
|
|
} else {
|