From ec2bc8b7cdd9005ea94146ee97ceffc023258c42 Mon Sep 17 00:00:00 2001 From: Trey Wallis <40307803+trey-wallis@users.noreply.github.com> Date: Sun, 21 Apr 2024 20:53:54 -0600 Subject: [PATCH] feat: save plugin version --- src/constants.ts | 3 ++- src/main.ts | 7 +++++++ src/types.ts | 9 +++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index e2ee9cc..25e9590 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -33,5 +33,6 @@ export const DEFAULT_SETTINGS: VaultExplorerPluginSettings = { } }, currentView: "grid", - pageSize: 50 + pageSize: 50, + pluginVersion: null } diff --git a/src/main.ts b/src/main.ts index 4fb4c04..2515624 100644 --- a/src/main.ts +++ b/src/main.ts @@ -95,7 +95,14 @@ export default class VaultExplorerPlugin extends Plugin { async loadSettings() { const data = await this.loadData(); + this.settings = Object.assign({}, DEFAULT_SETTINGS, data); + + //TODO handle migrations + // if (this.settings.pluginVersion === null) { + this.settings.pluginVersion = this.manifest.version; + await this.saveSettings(); + // } } async saveSettings() { diff --git a/src/types.ts b/src/types.ts index aee5ff2..3debbc8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -19,6 +19,11 @@ export interface VaultExplorerPluginSettings { }, currentView: CurrentView; pageSize: number; + pluginVersion: string | null; +} + +export interface CustomProperty { + name: string; } export interface TextPropertyFilter extends BasePropertyFilter { @@ -63,7 +68,3 @@ export type CurrentView = "grid" | "list"; export type SortFilter = "file-name-asc" | "file-name-desc" | "modified-asc" | "modified-desc"; export type TimestampFilter = "created-today" | "modified-today" | "created-this-week" | "modified-this-week" | "created-2-weeks" | "modified-2-weeks" | "all"; - -export type onSettingsChange = (value: VaultExplorerPluginSettings) => void; - -export type getCurrentSettings = () => VaultExplorerPluginSettings;