mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 19:27:25 +01:00
Fix extension update badge in bottom nav not updating
This commit is contained in:
parent
96618e9517
commit
6675de1a26
@ -5,9 +5,10 @@ import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.os.Environment
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.f2prateek.rx.preferences.Preference
|
||||
import com.f2prateek.rx.preferences.Preference as RxPreference
|
||||
import com.f2prateek.rx.preferences.RxSharedPreferences
|
||||
import com.tfcporciuncula.flow.FlowSharedPreferences
|
||||
import com.tfcporciuncula.flow.Preference
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
||||
@ -18,10 +19,17 @@ import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import reactivecircus.flowbinding.common.startWithCurrentValue
|
||||
|
||||
fun <T> Preference<T>.getOrDefault(): T = get() ?: defaultValue()!!
|
||||
fun <T> RxPreference<T>.getOrDefault(): T = get() ?: defaultValue()!!
|
||||
|
||||
private class DateFormatConverter : Preference.Adapter<DateFormat> {
|
||||
fun <T> Preference<T>.asImmediateFlow(): Flow<T> {
|
||||
return asFlow()
|
||||
.startWithCurrentValue(true) { get() }
|
||||
}
|
||||
|
||||
private class DateFormatConverter : RxPreference.Adapter<DateFormat> {
|
||||
override fun get(key: String, preferences: SharedPreferences): DateFormat {
|
||||
val dateFormat = preferences.getString(Keys.dateFormat, "")!!
|
||||
|
||||
|
@ -13,6 +13,7 @@ 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.asImmediateFlow
|
||||
import eu.kanade.tachiyomi.databinding.MainActivityBinding
|
||||
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
||||
@ -153,7 +154,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
||||
}
|
||||
}
|
||||
|
||||
preferences.extensionUpdatesCount().asFlow()
|
||||
preferences.extensionUpdatesCount().asImmediateFlow()
|
||||
.onEach { setExtensionsBadge(it) }
|
||||
.launchInUI()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user