From 79323de3268340a2b70a7f8539b94fab5d497df1 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. (cherry picked from commit b12c7cf9633a9fc3a728a0ef44b5d50d621a7595) --- .../presentation/components/DeleteLibraryMangaDialog.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/components/DeleteLibraryMangaDialog.kt b/app/src/main/java/eu/kanade/presentation/components/DeleteLibraryMangaDialog.kt index 52ee61559e..6d2b3b6cc1 100644 --- a/app/src/main/java/eu/kanade/presentation/components/DeleteLibraryMangaDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/components/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(