mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 04:37:25 +01:00
Avoid potential crash when opening library settings sheet (#9415)
This commit is contained in:
parent
058ee4c86b
commit
2cb08e6bb1
@ -530,7 +530,10 @@ class LibraryScreenModel(
|
||||
}
|
||||
|
||||
fun showSettingsDialog() {
|
||||
mutableState.update { it.copy(dialog = Dialog.SettingsSheet) }
|
||||
mutableState.update {
|
||||
val category = it.categories.getOrNull(activeCategoryIndex) ?: return@update it
|
||||
it.copy(dialog = Dialog.SettingsSheet(category))
|
||||
}
|
||||
}
|
||||
|
||||
fun clearSelection() {
|
||||
@ -651,7 +654,7 @@ class LibraryScreenModel(
|
||||
}
|
||||
|
||||
sealed class Dialog {
|
||||
object SettingsSheet : Dialog()
|
||||
data class SettingsSheet(val category: Category) : Dialog()
|
||||
data class ChangeCategory(val manga: List<Manga>, val initialSelection: List<CheckboxState<Category>>) : Dialog()
|
||||
data class DeleteManga(val manga: List<Manga>) : Dialog()
|
||||
}
|
||||
|
@ -205,11 +205,13 @@ object LibraryTab : Tab {
|
||||
|
||||
val onDismissRequest = screenModel::closeDialog
|
||||
when (val dialog = state.dialog) {
|
||||
is LibraryScreenModel.Dialog.SettingsSheet -> LibrarySettingsDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
screenModel = settingsScreenModel,
|
||||
category = state.categories[screenModel.activeCategoryIndex],
|
||||
)
|
||||
is LibraryScreenModel.Dialog.SettingsSheet -> {
|
||||
LibrarySettingsDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
screenModel = settingsScreenModel,
|
||||
category = dialog.category,
|
||||
)
|
||||
}
|
||||
is LibraryScreenModel.Dialog.ChangeCategory -> {
|
||||
ChangeCategoryDialog(
|
||||
initialSelection = dialog.initialSelection,
|
||||
|
Loading…
Reference in New Issue
Block a user