mirror of
https://github.com/devonthesofa/obsidian-note-status.git
synced 2026-07-22 05:45:04 +00:00
fix(settings): restore predefined templates as default and auto-enable them
This commit is contained in:
parent
630538037a
commit
da3bb8eeb1
2 changed files with 4 additions and 53 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue