From c1ae66243b4b0e4f4f01af0eb1b01d303836d74b Mon Sep 17 00:00:00 2001 From: Jeremy Valentine <38669521+valentine195@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:42:49 -0500 Subject: [PATCH] fix: disable event frontmatter writing, debounce save --- src/main.ts | 11 ++++++----- src/settings/modals/event/event.ts | 5 +++-- src/settings/settings.ts | 14 +++++++------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main.ts b/src/main.ts index 19f8fd2..985aa93 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { Notice, Platform, Plugin, WorkspaceLeaf } from "obsidian"; +import { debounce, Notice, Platform, Plugin, WorkspaceLeaf } from "obsidian"; import FantasyCalendarSettings from "./settings/settings"; @@ -388,6 +388,7 @@ export default class FantasyCalendar extends Plugin { }); } } + this.data.eventFrontmatter = false; await this.saveSettings(); this.settingsLoaded = true; @@ -416,10 +417,10 @@ export default class FantasyCalendar extends Plugin { return `${this.configDirectory}/data.json`; } async saveSettings() { - await this.saveData(this.data); + await this.save(this.data); this.app.workspace.trigger("fantasy-calendar-settings-change"); } - async saveData(data: FantasyCalendarData) { + save = debounce(async (data: FantasyCalendarData) => { if (this.configDirectory) { try { if ( @@ -438,6 +439,6 @@ export default class FantasyCalendar extends Plugin { ); } } - await super.saveData(data); - } + await this.saveData(data); + }, 200); } diff --git a/src/settings/modals/event/event.ts b/src/settings/modals/event/event.ts index 18f11d1..f8ec8da 100644 --- a/src/settings/modals/event/event.ts +++ b/src/settings/modals/event/event.ts @@ -132,8 +132,9 @@ export class CreateEventModal extends FantasyCalendarModal { } this.saved = true; if ( - this.plugin.data.eventFrontmatter && - this.event.note + false + /* this.plugin.data.eventFrontmatter && + this.event.note */ ) { const [path, subpath] = this.event.note.split(/[#^]/); diff --git a/src/settings/settings.ts b/src/settings/settings.ts index f1e1398..f081c06 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -411,14 +411,14 @@ export default class FantasyCalendarSettings extends PluginSettingTab { }); new Setting(containerEl) .setName("Write Event Data to Frontmatter") - .setDesc( - "Events linked to notes will write their data to the note frontmatter." - ) + .setDesc("This setting is temporarily disabled.") .addToggle((t) => { - t.setValue(this.data.eventFrontmatter).onChange(async (v) => { - this.data.eventFrontmatter = v; - await this.plugin.saveSettings(); - }); + t.setValue(false) + .setDisabled(true) + .onChange(async (v) => { + this.data.eventFrontmatter = v; + await this.plugin.saveSettings(); + }); }); new Setting(containerEl)