Avoid some IndexOutOfBoundsExceptions

(cherry picked from commit eb742b29f8)
This commit is contained in:
arkon
2022-10-21 16:45:26 -04:00
committed by Jobobby04
parent 08c6876742
commit d0f3bd077c
2 changed files with 12 additions and 8 deletions
@@ -93,10 +93,12 @@ fun ChangeCategoryDialog(
selection.forEach { checkbox ->
val onChange: (CheckboxState<Category>) -> Unit = {
val index = selection.indexOf(it)
val mutableList = selection.toMutableList()
mutableList.removeAt(index)
mutableList.add(index, it.next())
selection = mutableList.toList()
if (index != -1) {
val mutableList = selection.toMutableList()
mutableList.removeAt(index)
mutableList.add(index, it.next())
selection = mutableList.toList()
}
}
Row(
modifier = Modifier