Fix navigating out when all migrations are done or skipped

This commit is contained in:
Jobobby04 2022-11-29 20:12:24 -05:00
parent afbe097f76
commit b7561184ea

View File

@ -274,13 +274,16 @@ class MigrationListScreenModel(
} }
} }
private fun sourceFinished() { private suspend fun sourceFinished() {
unfinishedCount.value = migratingItems.value.count { unfinishedCount.value = migratingItems.value.count {
it.searchResult.value != SearchResult.Searching it.searchResult.value != SearchResult.Searching
} }
if (allMangasDone()) { if (allMangasDone()) {
migrationDone.value = true migrationDone.value = true
} }
if (migratingItems.value.isEmpty()) {
navigateOut()
}
} }
fun allMangasDone() = migratingItems.value.all { it.searchResult.value != SearchResult.Searching } && fun allMangasDone() = migratingItems.value.all { it.searchResult.value != SearchResult.Searching } &&
@ -481,12 +484,6 @@ class MigrationListScreenModel(
coroutineScope.launchIO { coroutineScope.launchIO {
val item = migratingItems.value.find { it.manga.id == mangaId } val item = migratingItems.value.find { it.manga.id == mangaId }
?: return@launchIO ?: return@launchIO
if (migratingItems.value.size == 1) {
item.searchResult.value = SearchResult.NotFound
item.migrationScope.cancel()
sourceFinished()
return@launchIO
}
removeManga(item) removeManga(item)
item.migrationScope.cancel() item.migrationScope.cancel()
sourceFinished() sourceFinished()