perf(settings): batch store registrations and defer font enumeration (#4058)

Settings pages, parent action proxies and template actions registered one by one, cloning the store map and notifying subscribers per item (~1,650 action and ~172 page updates per Settings open). registerActions now disposes in one update too, and the new registerSettingsPages batches page registration and disposal; both keep later per-id overrides. Disabled font pickers no longer enumerate system fonts; enabled ones defer it to idle and load at once on interaction, and the icon-font probe waits past startup.

Co-authored-by: dengliu <5108773+dengliu@users.noreply.github.com>
This commit is contained in:
Deng Liu
2026-11-18 09:10:40 +08:00
committed by GitHub
co-authored by dengliu
parent 0e169cc653
commit 606a66b5dd
14 changed files with 290 additions and 103 deletions
+22
View File
@@ -1212,6 +1212,28 @@ export function registerSettingsPage(page: SettingsPageContribution): () => void
});
}
/** Registers a batch of settings pages in one store update; returns a batched disposer. */
export function registerSettingsPages(list: SettingsPageContribution[]): () => void {
if (!list.length) return () => {};
const owned = new Map<string, SettingsPageContribution>();
for (const page of list) owned.set(page.id, page);
useSettingsPages.setState((s) => {
const pages = new Map(s.pages);
for (const [id, page] of owned) pages.set(id, page);
return { pages };
});
return () =>
useSettingsPages.setState((s) => {
let next: Map<string, SettingsPageContribution> | null = null;
for (const [id, page] of owned) {
if (s.pages.get(id) !== page) continue;
next ??= new Map(s.pages);
next.delete(id);
}
return next ? { pages: next } : s;
});
}
/** A searchable settings entry: a page, or an option label on it (Search Everywhere's "Settings: …" items). */
export interface SettingsSearchEntry {
pageId: string;