Fix migration "Attempt to invoke virtual method" crash (mihonapp/mihon#2632)

(cherry picked from commit 93ba6acea56334573fc506d593affd5bea2a86b2)
This commit is contained in:
AntsyLich 2025-11-01 01:42:42 +06:00 committed by Cuong-Tran
parent b28778221e
commit 9a3934eadf

View file

@ -406,13 +406,6 @@ class MigrationConfigScreen(private val mangaIds: List<Long>) : Screen() {
private val disabledSources by lazy { sourcePreferences.disabledSources().get().mapNotNull { it.toLongOrNull() } }
// KMK <--
init {
screenModelScope.launchIO {
initSources()
mutableState.update { it.copy(isLoading = false) }
}
}
private val sourcesComparator = { includedSources: /* KMK --> */ Map<Long, Int> /* KMK <-- */ ->
compareBy<MigrationSource>(
// KMK -->
@ -423,6 +416,13 @@ class MigrationConfigScreen(private val mangaIds: List<Long>) : Screen() {
)
}
init {
screenModelScope.launchIO {
initSources()
mutableState.update { it.copy(isLoading = false) }
}
}
private fun updateSources(save: Boolean = true, action: (List<MigrationSource>) -> List<MigrationSource>) {
mutableState.update { state ->
val updatedSources = action(state.sources)