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
df505a71b1
commit
9fd8a555f1
2 files changed
+13
-11
No files matched your search
@@ -118,12 +118,7 @@ private fun compareNatural(a: String, b: String): Int {
|
||||
j = endB
|
||||
}
|
||||
else -> {
|
||||
if (ca != cb) {
|
||||
val numeralA = !asciiA && isNumeralChar(ca)
|
||||
val numeralB = !asciiB && isNumeralChar(cb)
|
||||
if (numeralA != numeralB) return if (numeralA) -1 else 1
|
||||
return ca.compareTo(cb)
|
||||
}
|
||||
if (ca != cb) return ca.compareTo(cb)
|
||||
i++
|
||||
j++
|
||||
}
|
||||
|
||||
@@ -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