fix(settings): skip the startup scan when dictionaries are already loaded

A second activity instance (PROCESS_TEXT) ran the full directory scan
again, and the main screen stayed blank until the scan finished. The
repository is a process-wide singleton: when it already holds
dictionaries, mark them up to date and load preferences immediately.
This commit is contained in:
OneWay committed 2026-10-06 09:42:54 +08:00
1 parent 0c4ab6dad5
commit 5c655e769c
1 file changed
+6 -1
@@ -280,7 +280,12 @@ class SettingsViewModel(
var scanCompleted = false
viewModelScope.launch {
try {
scanCompleted = scanDirectoryInternal(preferencesManager.dictionaryPath) is OperationResult.Success
scanCompleted = if (localDictionaryRepository.dictionaries.value.isEmpty()) {
scanDirectoryInternal(preferencesManager.dictionaryPath) is OperationResult.Success
} else {
dictionaryStatus.value = DictionaryStatus.UpToDate
false
}
} catch (e: Exception) {
android.util.Log.e("SettingsViewModel", "Initial scan failed", e)
dictionaryStatus.value = if (localDictionaryRepository.dictionaries.value.isEmpty()) {