From ecf06693a180127ccf4d3aa69ad081fb2aff9671 Mon Sep 17 00:00:00 2001 From: Jarek Bird Date: Wed, 24 May 2023 00:32:23 -0600 Subject: [PATCH] Non Breaking Change Solution --- docs/advanced/dataview.md | 10 ++++++---- src/main.ts | 15 +++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/advanced/dataview.md b/docs/advanced/dataview.md index 3fc86c2..fa78a09 100644 --- a/docs/advanced/dataview.md +++ b/docs/advanced/dataview.md @@ -6,8 +6,8 @@ Create calendars inline with your notes from [dataviewjs](https://blacksmithgu.g ```dataviewjs this.container.style.minHeight = "500px"; const { renderCalendar } = app.plugins.plugins["obsidian-full-calendar"]; -renderCalendar(this.container, [[{start: new Date(), id: "id", title: "Now and for an hour"}]]) - .then(calendar => calendar.render()); +let calendar = renderCalendar(this.container, [[{start: new Date(), id: "id", title: "Now and for an hour"}]]); +calendar.render() ``` ```` @@ -16,8 +16,10 @@ renderCalendar(this.container, [[{start: new Date(), id: "id", title: "Now and f ```` ```dataviewjs this.container.style.minHeight = "500px"; -const { renderCalendar } = app.plugins.plugins["obsidian-full-calendar"]; -renderCalendar(this.container).then(calendar => calendar.render()); +const { renderCalendar, initializeSettings } = app.plugins.plugins["obsidian-full-calendar"]; +await initializeSettings(); +let calendar = renderCalendar(this.container); +calendar.render(); ``` ```` diff --git a/src/main.ts b/src/main.ts index 255f8ef..2b5ee4f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -64,15 +64,12 @@ export default class FullCalendarPlugin extends Plugin { }); translateSources = translateSources; - renderCalendar = async ( + renderCalendar = ( containerEl: HTMLElement, eventSources: EventSourceInput[], settings?: ExtraRenderProps ) => { if (!eventSources) { - if (!this.cache.initialized) { - await this.saveSettings(); - } eventSources = translateSources(this); } return calendarRender(containerEl, eventSources, settings); @@ -221,11 +218,17 @@ export default class FullCalendarPlugin extends Plugin { ); } - async saveSettings() { + initializeSettings = async () => { + if (!this.cache.initialized) { + await this.saveSettings(); + } + }; + + saveSettings = async () => { new Notice("Resetting the event cache with new settings..."); await this.saveData(this.settings); this.cache.reset(this.settings.calendarSources); await this.cache.populate(); this.cache.resync(); - } + }; }