avoid dictionary re-ordering on UI interaction

This commit is contained in:
Helium314 2025-06-02 20:41:52 +02:00
parent 7dbf5ea86d
commit 97aec851e4

View file

@ -57,7 +57,7 @@ fun DictionaryScreen(
val enabledLanguages = SubtypeSettings.getEnabledSubtypes(true).map { it.locale().language } val enabledLanguages = SubtypeSettings.getEnabledSubtypes(true).map { it.locale().language }
val cachedDictFolders = DictionaryInfoUtils.getCacheDirectories(ctx).map { it.name } val cachedDictFolders = DictionaryInfoUtils.getCacheDirectories(ctx).map { it.name }
val comparer = compareBy<Locale>({ it.language !in enabledLanguages }, { it.toLanguageTag() !in cachedDictFolders}, { it.displayName }) val comparer = compareBy<Locale>({ it.language !in enabledLanguages }, { it.toLanguageTag() !in cachedDictFolders}, { it.displayName })
val dictionaryLocales = getDictionaryLocales(ctx).sortedWith(comparer).toMutableList() val dictionaryLocales = remember { getDictionaryLocales(ctx).sortedWith(comparer).toMutableList() }
dictionaryLocales.add(0, Locale(SubtypeLocaleUtils.NO_LANGUAGE)) dictionaryLocales.add(0, Locale(SubtypeLocaleUtils.NO_LANGUAGE))
var selectedLocale: Locale? by remember { mutableStateOf(null) } var selectedLocale: Locale? by remember { mutableStateOf(null) }
var showAddDictDialog by remember { mutableStateOf(false) } var showAddDictDialog by remember { mutableStateOf(false) }