mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user