Skip to content

Commit

Permalink
handle readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Nov 25, 2024
1 parent a0901ce commit efed29a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/packages/state/src/recoil/sidebar/sidebar-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ export const mergeGroups = (
sink: State.SidebarGroup[],
source: State.SidebarGroup[]
) => {
const mapping = Object.fromEntries(sink.map((g) => [g.name, g]));
const configMapping = Object.fromEntries(source.map((g) => [g.name, g]));
// make copies, assume readonly
const mapping = Object.fromEntries(sink.map((g) => [g.name, { ...g }]));
const configMapping = Object.fromEntries(
source.map((g) => [g.name, { ...g }])
);

const sinkKeys = sink.map(({ name }) => name);
const sourceKeys = source.map(({ name }) => name);

Expand All @@ -76,8 +80,9 @@ export const mergeGroups = (
continue;
}

mapping[name].paths = mapping[name].paths ?? [];
merge(mapping[name].paths, source[i].paths);
// make copies, assume readonly
mapping[name].paths = [...(mapping[name].paths ?? [])];
merge(mapping[name].paths, [...source[i].paths]);
}

return resolved;
Expand Down

0 comments on commit efed29a

Please sign in to comment.