refactor(client/bundle): use type for parent name

This commit is contained in:
Elian Doran 2025-12-20 22:40:03 +02:00
parent e0416097e1
commit 64a770175f
No known key found for this signature in database

View File

@ -33,6 +33,8 @@ async function getAndExecuteBundle(noteId: string, originEntity = null, script =
return await executeBundle(bundle, originEntity); return await executeBundle(bundle, originEntity);
} }
export type ParentName = "left-pane" | "center-pane" | "note-detail-pane" | "right-pane";
export async function executeBundle(bundle: Bundle, originEntity?: Entity | null, $container?: JQuery<HTMLElement>) { export async function executeBundle(bundle: Bundle, originEntity?: Entity | null, $container?: JQuery<HTMLElement>) {
const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity, $container); const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity, $container);
@ -88,7 +90,7 @@ export class WidgetsByParent {
} }
} }
get(parentName: string) { get(parentName: ParentName) {
if (!this.legacyWidgets[parentName]) { if (!this.legacyWidgets[parentName]) {
return []; return [];
} }
@ -102,7 +104,7 @@ export class WidgetsByParent {
); );
} }
getPreactWidgets(parentName: string) { getPreactWidgets(parentName: ParentName) {
return this.preactWidgets[parentName] ?? []; return this.preactWidgets[parentName] ?? [];
} }
} }