fix(actions): preserve action command favorites during state refresh
This commit is contained in:
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user