Revert "Avoid potential crash when opening library settings sheet (#9415)"

This reverts commit 2cb08e6bb1.
This commit is contained in:
arkon 2023-04-28 10:11:13 -04:00
parent c21813a8b5
commit c590f55030
2 changed files with 7 additions and 12 deletions

View File

@ -530,10 +530,7 @@ class LibraryScreenModel(
} }
fun showSettingsDialog() { fun showSettingsDialog() {
mutableState.update { mutableState.update { it.copy(dialog = Dialog.SettingsSheet) }
val category = it.categories.getOrNull(activeCategoryIndex) ?: return@update it
it.copy(dialog = Dialog.SettingsSheet(category))
}
} }
fun clearSelection() { fun clearSelection() {
@ -654,7 +651,7 @@ class LibraryScreenModel(
} }
sealed class Dialog { sealed class Dialog {
data class SettingsSheet(val category: Category) : Dialog() object SettingsSheet : Dialog()
data class ChangeCategory(val manga: List<Manga>, val initialSelection: List<CheckboxState<Category>>) : Dialog() data class ChangeCategory(val manga: List<Manga>, val initialSelection: List<CheckboxState<Category>>) : Dialog()
data class DeleteManga(val manga: List<Manga>) : Dialog() data class DeleteManga(val manga: List<Manga>) : Dialog()
} }

View File

@ -205,13 +205,11 @@ object LibraryTab : Tab {
val onDismissRequest = screenModel::closeDialog val onDismissRequest = screenModel::closeDialog
when (val dialog = state.dialog) { when (val dialog = state.dialog) {
is LibraryScreenModel.Dialog.SettingsSheet -> { is LibraryScreenModel.Dialog.SettingsSheet -> LibrarySettingsDialog(
LibrarySettingsDialog( onDismissRequest = onDismissRequest,
onDismissRequest = onDismissRequest, screenModel = settingsScreenModel,
screenModel = settingsScreenModel, category = state.categories[screenModel.activeCategoryIndex],
category = dialog.category, )
)
}
is LibraryScreenModel.Dialog.ChangeCategory -> { is LibraryScreenModel.Dialog.ChangeCategory -> {
ChangeCategoryDialog( ChangeCategoryDialog(
initialSelection = dialog.initialSelection, initialSelection = dialog.initialSelection,