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
|
j = endB
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
if (ca != cb) {
|
if (ca != cb) return ca.compareTo(cb)
|
||||||
val numeralA = !asciiA && isNumeralChar(ca)
|
|
||||||
val numeralB = !asciiB && isNumeralChar(cb)
|
|
||||||
if (numeralA != numeralB) return if (numeralA) -1 else 1
|
|
||||||
return ca.compareTo(cb)
|
|
||||||
}
|
|
||||||
i++
|
i++
|
||||||
j++
|
j++
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ->
|
||||||
|
|||||||
Reference in new issue
Block a user