Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
fix: disable event frontmatter writing, debounce save
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Feb 22, 2023
1 parent e91a12e commit c1ae662
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
11 changes: 6 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Notice, Platform, Plugin, WorkspaceLeaf } from "obsidian";
import { debounce, Notice, Platform, Plugin, WorkspaceLeaf } from "obsidian";

import FantasyCalendarSettings from "./settings/settings";

Expand Down Expand Up @@ -388,6 +388,7 @@ export default class FantasyCalendar extends Plugin {
});
}
}
this.data.eventFrontmatter = false;
await this.saveSettings();

this.settingsLoaded = true;
Expand Down Expand Up @@ -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 (
Expand All @@ -438,6 +439,6 @@ export default class FantasyCalendar extends Plugin {
);
}
}
await super.saveData(data);
}
await this.saveData(data);
}, 200);
}
5 changes: 3 additions & 2 deletions src/settings/modals/event/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(/[#^]/);
Expand Down
14 changes: 7 additions & 7 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c1ae662

Please sign in to comment.