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:
1 parent
7deabeb02a
commit
9dac7507ed
1 file changed
+6
-1
@@ -277,7 +277,12 @@ class SettingsViewModel(
|
|||||||
var scanCompleted = false
|
var scanCompleted = false
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
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) {
|
} catch (e: Exception) {
|
||||||
android.util.Log.e("SettingsViewModel", "Initial scan failed", e)
|
android.util.Log.e("SettingsViewModel", "Initial scan failed", e)
|
||||||
dictionaryStatus.value = if (localDictionaryRepository.dictionaries.value.isEmpty()) {
|
dictionaryStatus.value = if (localDictionaryRepository.dictionaries.value.isEmpty()) {
|
||||||
|
|||||||
Reference in new issue
Block a user