Fix refreshing state for extensions tab

Fixes #8644
Also add an extra delay in case it's super fast.
This commit is contained in:
arkon 2022-11-29 09:25:17 -05:00
parent 8ad9337863
commit 8eda4df71f

View File

@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.extension.model.InstallStep
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.LocaleHelper
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.asStateFlow
@ -24,6 +25,7 @@ import kotlinx.coroutines.flow.update
import rx.Observable import rx.Observable
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import kotlin.time.Duration.Companion.seconds
class ExtensionsScreenModel( class ExtensionsScreenModel(
preferences: SourcePreferences = Injekt.get(), preferences: SourcePreferences = Injekt.get(),
@ -194,12 +196,17 @@ class ExtensionsScreenModel(
} }
fun findAvailableExtensions() { fun findAvailableExtensions() {
mutableState.update { it.copy(isRefreshing = true) }
coroutineScope.launchIO { coroutineScope.launchIO {
mutableState.update { it.copy(isRefreshing = true) }
extensionManager.findAvailableExtensions() extensionManager.findAvailableExtensions()
}
// Fake slower refresh so it doesn't seem like it's not doing anything
delay(1.seconds)
mutableState.update { it.copy(isRefreshing = false) } mutableState.update { it.copy(isRefreshing = false) }
} }
}
fun trustSignature(signatureHash: String) { fun trustSignature(signatureHash: String) {
extensionManager.trustSignature(signatureHash) extensionManager.trustSignature(signatureHash)