Browse Source

Avoid crash in DeleteLibraryMangaDialog

No clue why it ever gets a -1 index though.

(cherry picked from commit b12c7cf9633a9fc3a728a0ef44b5d50d621a7595)
arkon 2 years ago
parent
commit
79323de326

+ 5 - 3
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<Int>
-                        list = mutableList.toList()
+                        if (index != -1) {
+                            val mutableList = list.toMutableList()
+                            mutableList[index] = state.next() as CheckboxState.State<Int>
+                            list = mutableList.toList()
+                        }
                     }
 
                     Row(