Avoid some IndexOutOfBoundsExceptions

This commit is contained in:
arkon
2022-10-21 16:45:26 -04:00
parent d2e62ffb19
commit eb742b29f8
2 changed files with 12 additions and 8 deletions

View File

@@ -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