From da3bb8eeb1536d1eded686544b58118840502273 Mon Sep 17 00:00:00 2001 From: Aleix Soler Date: Thu, 19 Mar 2026 11:52:30 +0100 Subject: [PATCH] fix(settings): restore predefined templates as default and auto-enable them --- constants/defaultSettings.ts | 6 ++--- core/settingsService.ts | 51 +----------------------------------- 2 files changed, 4 insertions(+), 53 deletions(-) diff --git a/constants/defaultSettings.ts b/constants/defaultSettings.ts index 714fcc1..5462f69 100644 --- a/constants/defaultSettings.ts +++ b/constants/defaultSettings.ts @@ -1,5 +1,5 @@ import { PluginSettings } from "types/pluginSettings"; - +import { PREDEFINED_TEMPLATES } from "./predefinedTemplates"; export const DEFAULT_PLUGIN_SETTINGS: PluginSettings = { fileExplorerIconPosition: "absolute-right", fileExplorerIconFrame: "never", @@ -14,7 +14,7 @@ export const DEFAULT_PLUGIN_SETTINGS: PluginSettings = { showStatusBar: true, autoHideStatusBar: false, enableStatusOverviewPopup: true, - templates: [], + templates: JSON.parse(JSON.stringify(PREDEFINED_TEMPLATES)), customStatuses: [], showStatusIconsInExplorer: true, hideUnknownStatusInExplorer: true, // Default to hide unknown status @@ -26,7 +26,7 @@ export const DEFAULT_PLUGIN_SETTINGS: PluginSettings = { enableExperimentalFeatures: true, enableStatusDashboard: true, enableGroupedStatusView: true, - enabledTemplates: [], + enabledTemplates: PREDEFINED_TEMPLATES.map((t) => t.id), useCustomStatusesOnly: false, useMultipleStatuses: true, singleStatusStorageMode: "list", diff --git a/core/settingsService.ts b/core/settingsService.ts index 141599c..c5a68ca 100644 --- a/core/settingsService.ts +++ b/core/settingsService.ts @@ -117,9 +117,8 @@ class SettingsService { const hasTemplates = this.settings.templates && this.settings.templates.length > 0; - // 1. If it's a truly new user (no data at all), give them the starter template + // 1. If it's a truly new user (no data at all), wait, we now provide all templates in DEFAULT_PLUGIN_SETTINGS if (!loadedData) { - this.injectStarterTemplate(); return; } @@ -153,58 +152,10 @@ class SettingsService { // Update enabled list this.settings.enabledTemplates = toRestore.map((t) => t.id); this.saveSettings().catch(console.error); - } else { - // If nothing was enabled, just give them the starter template - this.injectStarterTemplate(); } } } - /** - * Injects the default starter template. - */ - private injectStarterTemplate() { - const starterTemplate = { - id: "starter", - name: "Starter Template", - description: - "A simplified set of essential workflow statuses to get you started.", - authorGithub: "soler1212", - statuses: [ - { - name: "todo", - icon: "📌", - color: "#F44336", - templateId: "starter", - }, - { - name: "inProgress", - icon: "⚙️", - color: "#2196F3", - templateId: "starter", - }, - { - name: "review", - icon: "👀", - color: "#9C27B0", - templateId: "starter", - }, - { - name: "done", - icon: "✓", - color: "#4CAF50", - templateId: "starter", - }, - ], - }; - - this.settings.templates = [starterTemplate]; - if (!this.settings.enabledTemplates.includes(starterTemplate.id)) { - this.settings.enabledTemplates.push(starterTemplate.id); - } - this.saveSettings().catch(console.error); - } - /** * Removes duplicate templates with the same name, keeping the first occurrence. */