From 8eda4df71f3e4ad5ff0f812b695a0164cc1828cd Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 29 Nov 2022 09:25:17 -0500 Subject: [PATCH] Fix refreshing state for extensions tab Fixes #8644 Also add an extra delay in case it's super fast. --- .../ui/browse/extension/ExtensionsScreenModel.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt index 0887e59735..7d31bd92a9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionsScreenModel.kt @@ -13,6 +13,7 @@ import eu.kanade.tachiyomi.extension.model.InstallStep import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.system.LocaleHelper +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow @@ -24,6 +25,7 @@ import kotlinx.coroutines.flow.update import rx.Observable import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import kotlin.time.Duration.Companion.seconds class ExtensionsScreenModel( preferences: SourcePreferences = Injekt.get(), @@ -194,11 +196,16 @@ class ExtensionsScreenModel( } fun findAvailableExtensions() { - mutableState.update { it.copy(isRefreshing = true) } coroutineScope.launchIO { + mutableState.update { it.copy(isRefreshing = true) } + 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) {