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 hasLoadedPreferences flipped
in the scan's finally block. 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 7deabeb02a
commit 9dac7507ed
1 file changed
+6 -1
@@ -277,7 +277,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()) {