Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,27 @@ Module.register("calendar", {

if (notification === "CALENDAR_EVENTS") {
if (this.hasCalendarURL(payload.url)) {
this.calendarData[payload.url] = payload.events;
// have we received events for this url
if (!this.calendarData[payload.url]) {
// no, setup the structure to hold the info
this.calendarData[payload.url] = { events: null, checksum: null };
}
// save the event list
this.calendarData[payload.url].events = payload.events;

this.error = null;
this.loaded = true;

if (this.config.broadcastEvents) {
this.broadcastEvents();
}
// if the checksum is the same
if (this.calendarData[payload.url].checksum === payload.checksum) {
// then don't update the UI
return;
}
// haven't seen or the checksum is different
this.calendarData[payload.url].checksum = payload.checksum;

if (!this.config.updateOnFetch) {
if (this.calendarDisplayer[payload.url] === undefined) {
Expand Down Expand Up @@ -602,7 +616,7 @@ Module.register("calendar", {
let events = [];

for (const calendarUrl in this.calendarData) {
const calendar = this.calendarData[calendarUrl];
const calendar = this.calendarData[calendarUrl].events;
Comment thread
sdetweil marked this conversation as resolved.
let remainingEntries = this.maximumEntriesForUrl(calendarUrl);
let maxPastDaysCompare = now.clone().subtract(this.maximumPastDaysForUrl(calendarUrl), "days");
let by_url_calevents = [];
Expand Down
5 changes: 4 additions & 1 deletion modules/default/calendar/node_helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const zlib = require("node:zlib");
const NodeHelper = require("node_helper");
const Log = require("logger");
const CalendarFetcher = require("./calendarfetcher");
Expand Down Expand Up @@ -90,10 +91,12 @@ module.exports = NodeHelper.create({
* @param {string} identifier the identifier of the calendar
*/
broadcastEvents (fetcher, identifier) {
const checksum = zlib.crc32(Buffer.from(JSON.stringify(fetcher.events), "utf8"));
this.sendSocketNotification("CALENDAR_EVENTS", {
id: identifier,
url: fetcher.url,
events: fetcher.events
events: fetcher.events,
checksum: checksum
});
}
});
Loading