fix(electrobun): eliminate remaining reactive cycles (tabs store + palette)
project-tabs-store: replaced Map reassignment (_tabs = new Map(_tabs)) with version counter pattern. Map reassignment created new object reference on every getActiveTab() call from $derived → infinite loop. CommandPalette: replaced $derived COMMANDS array with plain function call. $derived with .map() created new array every evaluation → infinite loop when any i18n state changed.
This commit is contained in:
parent
9d45caa8df
commit
86251f9d92
2 changed files with 22 additions and 21 deletions
|
|
@ -55,15 +55,17 @@
|
|||
{ id: 'zoom-out', labelKey: 'palette.zoomOut', shortcut: 'Ctrl+-', action: () => dispatch('zoom-out') },
|
||||
];
|
||||
|
||||
let COMMANDS = $derived<Command[]>(
|
||||
COMMAND_DEFS.map(d => ({
|
||||
// Build commands once — NOT $derived (creating new array per evaluation causes loops)
|
||||
function buildCommands(): Command[] {
|
||||
return COMMAND_DEFS.map(d => ({
|
||||
id: d.id,
|
||||
label: t(d.labelKey as any),
|
||||
description: d.descKey ? t(d.descKey as any) : undefined,
|
||||
shortcut: d.shortcut,
|
||||
action: d.action,
|
||||
}))
|
||||
);
|
||||
}));
|
||||
}
|
||||
let COMMANDS = buildCommands();
|
||||
|
||||
let query = $state('');
|
||||
let selectedIdx = $state(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue