From 5c8314a986687c5012a28a0412eb2636d2c0e577 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 24 Oct 2025 11:04:35 +0200 Subject: [PATCH] Enhances model loading in settings display Modifies display method to load models asynchronously in the background Improves user experience by: - Removing async modifier from display method - Handling model loading as a background task - Adding error handling for model loading - Preparing to update UI dynamically when models are loaded --- settings.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/settings.ts b/settings.ts index c250018..253ad7a 100644 --- a/settings.ts +++ b/settings.ts @@ -25,14 +25,23 @@ export class FreewritingCleanupSettingTab extends PluginSettingTab { this.plugin = plugin; } - async display(): Promise { + display(): void { const { containerEl } = this; containerEl.empty(); containerEl.createEl('h2', { text: 'Freewriting Cleanup Settings' }); - // Load models asynchronously - await this.loadModels(); + // Load models asynchronously in the background + this.loadModels() + .then(() => { + // Update dropdown UI when models are loaded + if (this.modelDropdown) { + this.populateModelDropdown(this.modelDropdown); + } + }) + .catch((error) => { + console.error('Error loading models in background:', error); + }); // MARK: - API Configuration