Avoid potential crash when opening library settings sheet 2.0 (#9419)

Avoid potential crash when opening library settings sheet  2.0

Previous one had issues
This commit is contained in:
AntsyLich 2023-04-29 01:15:54 +06:00 committed by GitHub
parent 7451c13edd
commit 6bdc1b676e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,11 +205,18 @@ 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 -> run {
onDismissRequest = onDismissRequest, val category = state.categories.getOrNull(screenModel.activeCategoryIndex)
screenModel = settingsScreenModel, if (category == null) {
category = state.categories[screenModel.activeCategoryIndex], onDismissRequest()
) return@run
}
LibrarySettingsDialog(
onDismissRequest = onDismissRequest,
screenModel = settingsScreenModel,
category = category,
)
}
is LibraryScreenModel.Dialog.ChangeCategory -> { is LibraryScreenModel.Dialog.ChangeCategory -> {
ChangeCategoryDialog( ChangeCategoryDialog(
initialSelection = dialog.initialSelection, initialSelection = dialog.initialSelection,