fix subsequent calendar fetcher timing

This commit is contained in:
Sam Detweiler
2020-10-11 22:39:42 -05:00
parent 6ec0aa8894
commit a3bad8aec4
2 changed files with 12 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ Module.register("calendar", {
timeFormat: "relative", timeFormat: "relative",
dateFormat: "MMM Do", dateFormat: "MMM Do",
dateEndFormat: "LT", dateEndFormat: "LT",
fullDayEventDateFormat: "MMM Do", fullDayEventDateFormat: "MMM Do HH:mm",
showEnd: false, showEnd: false,
getRelative: 6, getRelative: 6,
fadePoint: 0.25, // Start on 1/4th of the list. fadePoint: 0.25, // Start on 1/4th of the list.
@@ -41,7 +41,7 @@ Module.register("calendar", {
calendars: [ calendars: [
{ {
symbol: "calendar", symbol: "calendar",
url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics" url: "https://www.calendarlabs.com/templates/ical/US-Holidays.ics1"
} }
], ],
titleReplace: { titleReplace: {
@@ -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"];
@@ -114,12 +116,12 @@ Module.register("calendar", {
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 /* // Trigger ADD_CALENDAR every fetchInterval to make sure there is always a calendar
// fetcher running on the server side. // fetcher running on the server side.
var self = this; var self = this;
setInterval(function () { setInterval(function () {
self.addCalendar(calendar.url, calendar.auth, calendarConfig); self.addCalendar(calendar.url, calendar.auth, calendarConfig);
}, self.config.fetchInterval); }, self.config.fetchInterval); */
} }
this.calendarData = {}; this.calendarData = {};
@@ -541,6 +543,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,
@@ -554,6 +558,9 @@ Module.register("calendar", {
auth: auth, auth: auth,
broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents broadcastPastEvents: calendarConfig.broadcastPastEvents || this.config.broadcastPastEvents
}); });
setTimeout(() => {
self.addCalendar(url, auth, calendarConfig);
}, self.config.fetchInterval);
}, },
/** /**

View File

@@ -70,7 +70,7 @@ 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.broadcastEvents();
} }
fetcher.startFetch(); fetcher.startFetch();