Fix migration buttons sometimes doing nothing

This commit is contained in:
Jobobby04 2022-12-20 18:50:55 -05:00
parent 11b9a71034
commit 7a14d9e17b

View File

@ -62,24 +62,19 @@ class MigrationListScreen(private val config: MigrationProcedureConfig) : Screen
LaunchedEffect(screenModel) { LaunchedEffect(screenModel) {
screenModel.navigateOut.collect { screenModel.navigateOut.collect {
if (items.orEmpty().size == 1) { if (items.orEmpty().size == 1 && navigator.items.any { it is MangaScreen }) {
val hasDetails = navigator.items.any { it is MangaScreen } val mangaId = (items.orEmpty().firstOrNull()?.searchResult?.value as? MigratingManga.SearchResult.Result)?.id
if (hasDetails) { withUIContext {
val manga = (items.orEmpty().firstOrNull()?.searchResult?.value as? MigratingManga.SearchResult.Result)?.let { if (mangaId != null) {
screenModel.getManga(it.id) val newStack = navigator.items.filter {
} it !is MangaScreen &&
withUIContext { it !is MigrationListScreen &&
if (manga != null) { it !is PreMigrationScreen
val newStack = navigator.items.filter { } + MangaScreen(mangaId)
it !is MangaScreen && navigator replaceAll newStack.first()
it !is MigrationListScreen && navigator.push(newStack.drop(1))
it !is PreMigrationScreen } else {
} + MangaScreen(manga.id) navigator.pop()
navigator replaceAll newStack.first()
navigator.push(newStack.drop(1))
} else {
navigator.pop()
}
} }
} }
} else { } else {