diff --git a/CHANGELOG.md b/CHANGELOG.md index 5777142d..efd7e19d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ _This release is scheduled to be released on 2021-01-01._ - 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 diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index af804139..b2737586 100755 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -58,6 +58,8 @@ Module.register("calendar", { nextDaysRelative: false }, + requiresVersion: "2.1.0", + // Define required scripts. getStyles: function () { return ["calendar.css", "font-awesome.css"]; @@ -83,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://"); @@ -112,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. @@ -541,6 +541,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, diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 862755a0..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();