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
3 changed files with 13 additions and 11 deletions

View File

@@ -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,

View File

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