Batch select/deselect all updates to avoid N recompositions

Replace per-item forEach writes with a single putAll() call on the
SnapshotStateMap so all checked-state changes are applied in one
snapshot transaction, triggering a single recomposition instead of
one per item.

https://claude.ai/code/session_01PRSKjmFms1Tj1QJ5FhfqZm
This commit is contained in:
Claude
2026-03-20 11:52:48 +00:00
parent d97e87b89c
commit 8bee21a281
2 changed files with 4 additions and 4 deletions
@@ -133,14 +133,14 @@ fun BunkerMultiEventHomeScreen(
.fillMaxWidth()
.clickable {
val newValue = allCheckedState != ToggleableState.On
bunkerRequests.forEach { MultiEventScreenIntents.checkedStates[it.request.id] = newValue }
MultiEventScreenIntents.checkedStates.putAll(bunkerRequests.associate { it.request.id to newValue })
},
) {
TriStateCheckbox(
state = allCheckedState,
onClick = {
val newValue = allCheckedState != ToggleableState.On
bunkerRequests.forEach { MultiEventScreenIntents.checkedStates[it.request.id] = newValue }
MultiEventScreenIntents.checkedStates.putAll(bunkerRequests.associate { it.request.id to newValue })
},
)
Text(stringResource(R.string.select_deselect_all))
@@ -141,14 +141,14 @@ fun IntentMultiEventHomeScreen(
.fillMaxWidth()
.clickable {
val newValue = allCheckedState != ToggleableState.On
intents.forEach { MultiEventScreenIntents.checkedStates[it.id] = newValue }
MultiEventScreenIntents.checkedStates.putAll(intents.associate { it.id to newValue })
},
) {
TriStateCheckbox(
state = allCheckedState,
onClick = {
val newValue = allCheckedState != ToggleableState.On
intents.forEach { MultiEventScreenIntents.checkedStates[it.id] = newValue }
MultiEventScreenIntents.checkedStates.putAll(intents.associate { it.id to newValue })
},
)
Text(stringResource(R.string.select_deselect_all))