From 6bdc1b676e5ca4c3c8255ced835aa7d6bf7999d5 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sat, 29 Apr 2023 01:15:54 +0600 Subject: [PATCH] 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 --- .../kanade/tachiyomi/ui/library/LibraryTab.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt index cdf60ae05..1324c9133 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryTab.kt @@ -205,11 +205,18 @@ 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 -> run { + val category = state.categories.getOrNull(screenModel.activeCategoryIndex) + if (category == null) { + onDismissRequest() + return@run + } + LibrarySettingsDialog( + onDismissRequest = onDismissRequest, + screenModel = settingsScreenModel, + category = category, + ) + } is LibraryScreenModel.Dialog.ChangeCategory -> { ChangeCategoryDialog( initialSelection = dialog.initialSelection,