mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-21 17:01:51 +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() {
|
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() {
|
fun clearSelection() {
|
||||||
@ -651,7 +654,7 @@ class LibraryScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
sealed class Dialog {
|
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 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()
|
||||||
}
|
}
|
||||||
|
@ -205,11 +205,13 @@ 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 -> LibrarySettingsDialog(
|
is LibraryScreenModel.Dialog.SettingsSheet -> {
|
||||||
onDismissRequest = onDismissRequest,
|
LibrarySettingsDialog(
|
||||||
screenModel = settingsScreenModel,
|
onDismissRequest = onDismissRequest,
|
||||||
category = state.categories[screenModel.activeCategoryIndex],
|
screenModel = settingsScreenModel,
|
||||||
)
|
category = dialog.category,
|
||||||
|
)
|
||||||
|
}
|
||||||
is LibraryScreenModel.Dialog.ChangeCategory -> {
|
is LibraryScreenModel.Dialog.ChangeCategory -> {
|
||||||
ChangeCategoryDialog(
|
ChangeCategoryDialog(
|
||||||
initialSelection = dialog.initialSelection,
|
initialSelection = dialog.initialSelection,
|
||||||
|
Loading…
Reference in New Issue
Block a user