Skip to content

Commit

Permalink
Non Breaking Change Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
jarekbird committed May 24, 2023
1 parent 918e058 commit ecf0669
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
10 changes: 6 additions & 4 deletions docs/advanced/dataview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```
````

Expand All @@ -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();
```
````

Expand Down
15 changes: 9 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
};
}

0 comments on commit ecf0669

Please sign in to comment.