From a3bad8aec41e4d7f09588b1bf5fcea39f8b92359 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 11 Oct 2020 22:39:42 -0500 Subject: [PATCH 1/4] fix subsequent calendar fetcher timing --- modules/default/calendar/calendar.js | 15 +++++++++++---- modules/default/calendar/node_helper.js | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index af804139..5a8c2628 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -29,7 +29,7 @@ Module.register("calendar", { timeFormat: "relative", dateFormat: "MMM Do", dateEndFormat: "LT", - fullDayEventDateFormat: "MMM Do", + fullDayEventDateFormat: "MMM Do HH:mm", showEnd: false, getRelative: 6, fadePoint: 0.25, // Start on 1/4th of the list. @@ -41,7 +41,7 @@ Module.register("calendar", { calendars: [ { symbol: "calendar", - url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics" + url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics1" } ], titleReplace: { @@ -58,6 +58,8 @@ Module.register("calendar", { nextDaysRelative: false }, + requiresVersion: "2.1.0", + // Define required scripts. getStyles: function () { return ["calendar.css", "font-awesome.css"]; @@ -114,12 +116,12 @@ Module.register("calendar", { this.addCalendar(calendar.url, calendar.auth, calendarConfig); - // Trigger ADD_CALENDAR every fetchInterval to make sure there is always a calendar + /* // Trigger ADD_CALENDAR every fetchInterval to make sure there is always a calendar // fetcher running on the server side. var self = this; setInterval(function () { self.addCalendar(calendar.url, calendar.auth, calendarConfig); - }, self.config.fetchInterval); + }, self.config.fetchInterval); */ } this.calendarData = {}; @@ -541,6 +543,8 @@ Module.register("calendar", { * @param {object} calendarConfig The config of the specific calendar */ addCalendar: function (url, auth, calendarConfig) { + var self = this; + this.sendSocketNotification("ADD_CALENDAR", { id: this.identifier, url: url, @@ -554,6 +558,9 @@ Module.register("calendar", { auth: auth, broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents }); + setTimeout(() => { + self.addCalendar(url, auth, calendarConfig); + }, self.config.fetchInterval); }, /** diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 862755a0..1c88b9af 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -70,7 +70,7 @@ module.exports = NodeHelper.create({ } else { Log.log("Use existing calendar fetcher for url: " + url); fetcher = self.fetchers[identifier + url]; - fetcher.broadcastEvents(); + //fetcher.broadcastEvents(); } fetcher.startFetch(); From e8f60d39de8ad8d9b44d63362698a6e8e2c9146f Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Sun, 11 Oct 2020 22:43:11 -0500 Subject: [PATCH 2/4] fix subsequent calendar fetcher timing --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08610111..c360e511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ _This release is scheduled to be released on 2021-01-01._ ### Fixed +- JSON Parse translation files with comments crashing UI. (#2149) +- Calendar parsing where RRULE bug returns wrong date, add Windows timezone name support. (#2145, #2151) +- Wrong node-ical version installed (package.json) requested version. (#2153) +- Fix calendar fetcher subsequent timing (#2160) + ## [2.13.0] - 2020-10-01 Special thanks to the following contributors: @bryanzzhu, @bugsounet, @chamakura, @cjbrunner, @easyas314, @larryare, @oemel09, @rejas, @sdetweil & @sthuber90. From 4a7cb88a3e8f55131ad1c78c7d58781dc8f813f8 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 12 Oct 2020 09:01:50 -0500 Subject: [PATCH 3/4] typo, remove dead code, comments, fix recurring refresh, let fetcher handle it --- modules/default/calendar/calendar.js | 25 +++++++++------------ modules/default/calendar/calendarfetcher.js | 7 ++---- modules/default/calendar/node_helper.js | 1 - 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 5a8c2628..b2737586 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -29,7 +29,7 @@ Module.register("calendar", { timeFormat: "relative", dateFormat: "MMM Do", dateEndFormat: "LT", - fullDayEventDateFormat: "MMM Do HH:mm", + fullDayEventDateFormat: "MMM Do", showEnd: false, getRelative: 6, fadePoint: 0.25, // Start on 1/4th of the list. @@ -41,7 +41,7 @@ Module.register("calendar", { calendars: [ { symbol: "calendar", - url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics1" + url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics" } ], titleReplace: { @@ -85,6 +85,12 @@ Module.register("calendar", { // Set locale. moment.updateLocale(config.language, this.getLocaleSpecification(config.timeFormat)); + // clear data holder before start + this.calendarData = {}; + + // indicate no data available yet + this.loaded = false; + for (var c in this.config.calendars) { var calendar = this.config.calendars[c]; calendar.url = calendar.url.replace("webcal://", "http://"); @@ -114,18 +120,10 @@ Module.register("calendar", { }; } + // tell helper to start a fetcher for this calendar + // fetcher till cycle this.addCalendar(calendar.url, calendar.auth, calendarConfig); - - /* // Trigger ADD_CALENDAR every fetchInterval to make sure there is always a calendar - // fetcher running on the server side. - var self = this; - setInterval(function () { - self.addCalendar(calendar.url, calendar.auth, calendarConfig); - }, self.config.fetchInterval); */ } - - this.calendarData = {}; - this.loaded = false; }, // Override socket notification handler. @@ -558,9 +556,6 @@ Module.register("calendar", { auth: auth, broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents }); - setTimeout(() => { - self.addCalendar(url, auth, calendarConfig); - }, self.config.fetchInterval); }, /** diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 964cb955..8ea982f8 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -340,11 +340,8 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } }); - newEvents.sort(function (a, b) { - return a.startDate - b.startDate; - }); - - events = newEvents.slice(0, maximumEntries); + // send all our events to upper to merge, sort and reduce for display + events = newEvents; self.broadcastEvents(); scheduleTimer(); diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 1c88b9af..06fa28ec 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -70,7 +70,6 @@ module.exports = NodeHelper.create({ } else { Log.log("Use existing calendar fetcher for url: " + url); fetcher = self.fetchers[identifier + url]; - //fetcher.broadcastEvents(); } fetcher.startFetch(); From 485f662d7553c1bc8dcd086e3c1db1d4e869b255 Mon Sep 17 00:00:00 2001 From: Sam Detweiler Date: Mon, 12 Oct 2020 10:12:47 -0500 Subject: [PATCH 4/4] revert fetcher filtering results --- modules/default/calendar/calendarfetcher.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index ca0d6cd9..f153f7c0 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -395,8 +395,11 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn } }); - // send all our events to upper to merge, sort and reduce for display - events = newEvents; + newEvents.sort(function (a, b) { + return a.startDate - b.startDate; + }); + + events = newEvents.slice(0, maximumEntries); self.broadcastEvents(); scheduleTimer();