fix(actions): preserve action command favorites during state refresh

This commit is contained in:
Masterluke77
2026-07-14 13:59:32 +02:00
parent bd6c68dee3
commit ebb2849ad7
+7 -5
View File
@@ -175,9 +175,11 @@
|| left.title.localeCompare(right.title, 'de-DE', { sensitivity: 'base' }));
}
function syncCommandAdapter(action) {
commandDisposers.get(action.id)?.();
commandDisposers.delete(action.id);
function syncCommandAdapter(action, { preserveExisting = false } = {}) {
if (!preserveExisting) {
commandDisposers.get(action.id)?.();
commandDisposers.delete(action.id);
}
if (!action.surfaces.includes('command-palette') || !window.VendooCommands?.register) return;
const dispose = window.VendooCommands.register({
@@ -446,8 +448,8 @@
}
function refresh(actionId = null) {
if (actionId && registry.has(actionId)) syncCommandAdapter(registry.get(actionId));
else if (!actionId) registry.forEach(syncCommandAdapter);
if (actionId && registry.has(actionId)) syncCommandAdapter(registry.get(actionId), { preserveExisting: true });
else if (!actionId) registry.forEach(action => syncCommandAdapter(action, { preserveExisting: true }));
refreshDom();
mountedSurfaces.forEach(entry => {
try { entry.render(); } catch {}