mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
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:
+2
-2
@@ -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))
|
||||
|
||||
+2
-2
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user