Merge pull request #2162 from sdetweil/fixfetch

Fix calendar subsequent fetch timing with multiple calendar entries
This commit is contained in:
Michael Teeuw 2020-10-13 09:13:28 +02:00 committed by GitHub
commit 8c04712784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View File

@ -21,6 +21,7 @@ _This release is scheduled to be released on 2021-01-01._
- JSON Parse translation files with comments crashing UI. (#2149) - JSON Parse translation files with comments crashing UI. (#2149)
- Calendar parsing where RRULE bug returns wrong date, add Windows timezone name support. (#2145, #2151) - 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) - Wrong node-ical version installed (package.json) requested version. (#2153)
- Fix calendar fetcher subsequent timing (#2160)
## [2.13.0] - 2020-10-01 ## [2.13.0] - 2020-10-01

View File

@ -58,6 +58,8 @@ Module.register("calendar", {
nextDaysRelative: false nextDaysRelative: false
}, },
requiresVersion: "2.1.0",
// Define required scripts. // Define required scripts.
getStyles: function () { getStyles: function () {
return ["calendar.css", "font-awesome.css"]; return ["calendar.css", "font-awesome.css"];
@ -83,6 +85,12 @@ Module.register("calendar", {
// Set locale. // Set locale.
moment.updateLocale(config.language, this.getLocaleSpecification(config.timeFormat)); 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) { for (var c in this.config.calendars) {
var calendar = this.config.calendars[c]; var calendar = this.config.calendars[c];
calendar.url = calendar.url.replace("webcal://", "http://"); 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); 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. // Override socket notification handler.
@ -541,6 +541,8 @@ Module.register("calendar", {
* @param {object} calendarConfig The config of the specific calendar * @param {object} calendarConfig The config of the specific calendar
*/ */
addCalendar: function (url, auth, calendarConfig) { addCalendar: function (url, auth, calendarConfig) {
var self = this;
this.sendSocketNotification("ADD_CALENDAR", { this.sendSocketNotification("ADD_CALENDAR", {
id: this.identifier, id: this.identifier,
url: url, url: url,

View File

@ -70,7 +70,6 @@ module.exports = NodeHelper.create({
} else { } else {
Log.log("Use existing calendar fetcher for url: " + url); Log.log("Use existing calendar fetcher for url: " + url);
fetcher = self.fetchers[identifier + url]; fetcher = self.fetchers[identifier + url];
fetcher.broadcastEvents();
} }
fetcher.startFetch(); fetcher.startFetch();