Persist explicit provider toggles through the layer state coordinator

This commit is contained in:
Sameh Khamis committed 2026-10-09 19:09:30 -07:00
1 parent 3ba8c6d61b
commit eacfc1b06a
7 files changed
+152 -23

No files matched your search

+16
View File
@@ -45,3 +45,19 @@ export function decodeIdSwitches(value) {
: [],
);
}
/** Persist only explicitly requested switch IDs, not unrelated live changes. */
export function patchRequestedIdSwitches(previous, applied, requested) {
const current = decodeIdSwitches(applied);
const next = new Map(
[...decodeIdSwitches(previous)].filter(([id]) => current.has(id)),
);
let changed = false;
for (const [id, on] of current) {
if (Object.hasOwn(requested, id) && typeof requested[id] === 'boolean') {
next.set(id, on);
changed = true;
}
}
return changed ? encodeIdSwitches(next) : undefined;
}