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:
1 parent
74f88b6eb0
commit
aea2e35cbc
1 file changed
+12
-5
@@ -216,14 +216,21 @@ class SettingsViewModel(
|
||||
}
|
||||
}
|
||||
is DownloadState.Error -> {
|
||||
val startedHere = statusBeforeDownload != DictionaryStatus.Unknown ||
|
||||
isDownloadInProgress
|
||||
isDownloadInProgress = false
|
||||
if (!errorStateHandled) {
|
||||
errorStateHandled = true
|
||||
dictionaryStatus.value = if (dictionaryState.dictionaries.isEmpty()) {
|
||||
DictionaryStatus.Empty
|
||||
} else when (statusBeforeDownload) {
|
||||
DictionaryStatus.Unknown, DictionaryStatus.Checking -> DictionaryStatus.UpToDate
|
||||
else -> statusBeforeDownload
|
||||
if (dictionaryState.dictionaries.isEmpty()) {
|
||||
dictionaryStatus.value = DictionaryStatus.Empty
|
||||
} else if (startedHere) {
|
||||
when (statusBeforeDownload) {
|
||||
DictionaryStatus.Unknown, DictionaryStatus.Checking ->
|
||||
viewModelScope.launch {
|
||||
restoreOrEvaluateDictionaryStatus()
|
||||
}
|
||||
else -> dictionaryStatus.value = statusBeforeDownload
|
||||
}
|
||||
}
|
||||
if (pendingSourceUrls.isNotEmpty()) {
|
||||
pendingSourceUrls.forEach { urlTemplate ->
|
||||
|
||||
Reference in new issue
Block a user