fix(settings): keep the update badge after a failed download

Errors of downloads this screen did not start no longer touch the
status; when the prior status is unknown or still unresolved, today's
persisted status is restored or a fresh evaluation runs instead of
fabricating UpToDate.
This commit is contained in:
OneWay committed 2026-10-15 13:34:09 +08:00
1 parent 74f88b6eb0
commit aea2e35cbc
1 file changed
+12 -5
@@ -216,14 +216,21 @@ class SettingsViewModel(
} }
} }
is DownloadState.Error -> { is DownloadState.Error -> {
val startedHere = statusBeforeDownload != DictionaryStatus.Unknown ||
isDownloadInProgress
isDownloadInProgress = false isDownloadInProgress = false
if (!errorStateHandled) { if (!errorStateHandled) {
errorStateHandled = true errorStateHandled = true
dictionaryStatus.value = if (dictionaryState.dictionaries.isEmpty()) { if (dictionaryState.dictionaries.isEmpty()) {
DictionaryStatus.Empty dictionaryStatus.value = DictionaryStatus.Empty
} else when (statusBeforeDownload) { } else if (startedHere) {
DictionaryStatus.Unknown, DictionaryStatus.Checking -> DictionaryStatus.UpToDate when (statusBeforeDownload) {
else -> statusBeforeDownload DictionaryStatus.Unknown, DictionaryStatus.Checking ->
viewModelScope.launch {
restoreOrEvaluateDictionaryStatus()
}
else -> dictionaryStatus.value = statusBeforeDownload
}
} }
if (pendingSourceUrls.isNotEmpty()) { if (pendingSourceUrls.isNotEmpty()) {
pendingSourceUrls.forEach { urlTemplate -> pendingSourceUrls.forEach { urlTemplate ->