From 8e19f6bc8ff3f07001b756279692bd6275ce2376 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 24 Oct 2025 11:23:29 +0200 Subject: [PATCH] Simplifies data loading and initialization logic Combines data loading for settings and model cache Reduces redundant data loading steps and improves initialization efficiency Supports dynamic model handling on the dynamic-models branch --- main.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index 7a9969e..16f05d9 100644 --- a/main.ts +++ b/main.ts @@ -17,7 +17,9 @@ export default class FreewritingPromptsPlugin extends Plugin { noteCommand: NotePromptsCommand; async onload() { - await this.loadSettings(); + // Load data once and use it for both settings and model cache + const data = await this.loadData() as FreewritingPromptsData | null; + this.settings = Object.assign({}, DEFAULT_SETTINGS, data); // Initialize services this.promptGenerator = new PromptGeneratorService(this.settings); @@ -26,7 +28,6 @@ export default class FreewritingPromptsPlugin extends Plugin { this.noteCommand = new NotePromptsCommand(this.promptGenerator); // Load model cache - const data = await this.loadData() as FreewritingPromptsData | null; if (data?.modelCache) { this.modelService.loadCache(data.modelCache); }