Fix migration's selected sources order not preserved (#2993)

This commit is contained in:
AntsyLich
2026-02-25 17:04:24 +06:00
committed by GitHub
parent 89bbdb17fb
commit 47816d4b21
2 changed files with 6 additions and 3 deletions
@@ -330,13 +330,13 @@ class MigrationConfigScreen(private val mangaIds: Collection<Long>) : Screen() {
}
}
private fun updateSources(save: Boolean = true, action: (List<MigrationSource>) -> List<MigrationSource>) {
private fun updateSources(action: (List<MigrationSource>) -> List<MigrationSource>) {
mutableState.update { state ->
val updatedSources = action(state.sources)
val includedSources = updatedSources.mapNotNull { if (!it.isSelected) null else it.id }
state.copy(sources = updatedSources.sortedWith(sourcesComparator(includedSources)))
}
if (save) saveSources()
saveSources()
}
private fun initSources() {
@@ -368,7 +368,9 @@ class MigrationConfigScreen(private val mangaIds: Collection<Long>) : Screen() {
}
.toList()
updateSources(save = false) { sources }
mutableState.update { state ->
state.copy(sources = sources.sortedWith(sourcesComparator(includedSources)))
}
}
fun toggleSelection(id: Long) {