Fix extension download stuck at pending state in some cases (mihonapp/mihon#2483)
Also auto update extension list whenever a repository is added or removed Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> (cherry picked from commit 87c6f34a558b009be4d316e396ec3eeb4cfbbbf8)
This commit is contained in:
parent
aca83212c3
commit
dfacf681fa
3 changed files with 6 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ import cafe.adriel.voyager.core.model.StateScreenModel
|
|||
import cafe.adriel.voyager.core.model.screenModelScope
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import kotlinx.collections.immutable.ImmutableSet
|
||||
import kotlinx.collections.immutable.toImmutableSet
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
|
|
@ -30,6 +31,7 @@ class ExtensionReposScreenModel(
|
|||
private val deleteExtensionRepo: DeleteExtensionRepo = Injekt.get(),
|
||||
private val replaceExtensionRepo: ReplaceExtensionRepo = Injekt.get(),
|
||||
private val updateExtensionRepo: UpdateExtensionRepo = Injekt.get(),
|
||||
private val extensionManager: ExtensionManager = Injekt.get(),
|
||||
// KMK -->
|
||||
private val sourcePreferences: SourcePreferences = Injekt.get(),
|
||||
// KMK <--
|
||||
|
|
@ -75,6 +77,7 @@ class ExtensionReposScreenModel(
|
|||
fun createRepo(baseUrl: String) {
|
||||
screenModelScope.launchIO {
|
||||
when (val result = createExtensionRepo.await(baseUrl)) {
|
||||
CreateExtensionRepo.Result.Success -> extensionManager.findAvailableExtensions()
|
||||
CreateExtensionRepo.Result.InvalidUrl -> _events.send(RepoEvent.InvalidUrl)
|
||||
CreateExtensionRepo.Result.RepoAlreadyExists -> _events.send(RepoEvent.RepoAlreadyExists)
|
||||
is CreateExtensionRepo.Result.DuplicateFingerprint -> {
|
||||
|
|
@ -119,6 +122,7 @@ class ExtensionReposScreenModel(
|
|||
// KMK <--
|
||||
screenModelScope.launchIO {
|
||||
deleteExtensionRepo.await(baseUrl)
|
||||
extensionManager.findAvailableExtensions()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ class ExtensionManager(
|
|||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
withUIContext { context.toast(MR.strings.extension_api_error) }
|
||||
emptyList()
|
||||
return
|
||||
}
|
||||
|
||||
enableAdditionalSubLanguages(extensions)
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ class ExtensionsScreenModel(
|
|||
|
||||
fun cancelInstallUpdateExtension(extension: Extension) {
|
||||
extensionManager.cancelInstallUpdateExtension(extension)
|
||||
removeDownloadState(extension)
|
||||
}
|
||||
|
||||
private fun addDownloadState(extension: Extension, installStep: InstallStep) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue