From b12c7cf9633a9fc3a728a0ef44b5d50d621a7595 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 25 Feb 2023 15:29:00 -0500 Subject: [PATCH] Avoid crash in DeleteLibraryMangaDialog No clue why it ever gets a -1 index though. --- .../presentation/library/DeleteLibraryMangaDialog.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/library/DeleteLibraryMangaDialog.kt b/app/src/main/java/eu/kanade/presentation/library/DeleteLibraryMangaDialog.kt index b20c266ce..beb231baf 100644 --- a/app/src/main/java/eu/kanade/presentation/library/DeleteLibraryMangaDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/library/DeleteLibraryMangaDialog.kt @@ -64,9 +64,11 @@ fun DeleteLibraryMangaDialog( list.forEach { state -> val onCheck = { val index = list.indexOf(state) - val mutableList = list.toMutableList() - mutableList[index] = state.next() as CheckboxState.State - list = mutableList.toList() + if (index != -1) { + val mutableList = list.toMutableList() + mutableList[index] = state.next() as CheckboxState.State + list = mutableList.toList() + } } Row(