From 9adf4d7e8e1af1430d6db0385fa619a89a4f957e Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 5 Jul 2021 15:50:21 +0200 Subject: [PATCH] fixed calendar widget when open in a non-date note --- src/public/app/services/tab_manager.js | 16 ++++++++-------- src/public/app/widgets/buttons/calendar_menu.js | 9 +++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/public/app/services/tab_manager.js b/src/public/app/services/tab_manager.js index 239d4e1f3..d9dad8f91 100644 --- a/src/public/app/services/tab_manager.js +++ b/src/public/app/services/tab_manager.js @@ -313,10 +313,10 @@ export default class TabManager extends Component { const idx = this.mainNoteContexts.findIndex(nc => nc.ntxId === noteContextToRemove.ntxId); if (idx === this.mainNoteContexts.length - 1) { - this.activatePreviousTabCommand(); + await this.activatePreviousTabCommand(); } else { - this.activateNextTabCommand(); + await this.activateNextTabCommand(); } } @@ -356,22 +356,22 @@ export default class TabManager extends Component { this.tabsUpdate.scheduleUpdate(); } - activateNextTabCommand() { + async activateNextTabCommand() { const oldIdx = this.mainNoteContexts.findIndex(nc => nc.ntxId === this.activeNtxId); const newActiveTabId = this.mainNoteContexts[oldIdx === this.noteContexts.length - 1 ? 0 : oldIdx + 1].ntxId; - this.activateNoteContext(newActiveTabId); + await this.activateNoteContext(newActiveTabId); } - activatePreviousTabCommand() { + async activatePreviousTabCommand() { const oldIdx = this.mainNoteContexts.findIndex(nc => nc.ntxId === this.activeNtxId); const newActiveTabId = this.mainNoteContexts[oldIdx === 0 ? this.noteContexts.length - 1 : oldIdx - 1].ntxId; - this.activateNoteContext(newActiveTabId); + await this.activateNoteContext(newActiveTabId); } - closeActiveTabCommand() { - this.removeNoteContext(this.activeNtxId); + async closeActiveTabCommand() { + await this.removeNoteContext(this.activeNtxId); } beforeUnloadEvent() { diff --git a/src/public/app/widgets/buttons/calendar_menu.js b/src/public/app/widgets/buttons/calendar_menu.js index cf7d801c3..871349ce8 100644 --- a/src/public/app/widgets/buttons/calendar_menu.js +++ b/src/public/app/widgets/buttons/calendar_menu.js @@ -86,9 +86,10 @@ export default class CalendarMenuWidget extends BasicWidget { } init($el, activeDate) { - this.activeDate = new Date(activeDate + "T12:00:00"); // attaching time fixes local timezone handling + // attaching time fixes local timezone handling + this.activeDate = activeDate ? new Date(activeDate + "T12:00:00") : null; this.todaysDate = new Date(); - this.date = new Date(this.activeDate.getTime()); + this.date = new Date((this.activeDate || this.todaysDate).getTime()); this.date.setDate(1); this.createMonth(); @@ -129,6 +130,10 @@ export default class CalendarMenuWidget extends BasicWidget { } isEqual(a, b) { + if (!a && b || a && !b) { + return false; + } + return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();