From 26cb9548ec9994688c7eb1d58943b24cc82fe30b Mon Sep 17 00:00:00 2001 From: sam detweiler Date: Fri, 12 Dec 2025 12:20:46 -0600 Subject: [PATCH 1/2] add checksum to test whether event list changed --- modules/default/calendar/calendar.js | 18 ++++++++++++++++-- modules/default/calendar/node_helper.js | 5 ++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 07a20697e1..824e31491c 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -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 data for this url + if (!this.calendarData[payload.url]) { + // no,m setup tehe structure + 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) { @@ -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; let remainingEntries = this.maximumEntriesForUrl(calendarUrl); let maxPastDaysCompare = now.clone().subtract(this.maximumPastDaysForUrl(calendarUrl), "days"); let by_url_calevents = []; diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 474d0ecb55..5b717b5b1b 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -1,3 +1,4 @@ +const zlib = require("node:zlib"); const NodeHelper = require("node_helper"); const Log = require("logger"); const CalendarFetcher = require("./calendarfetcher"); @@ -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 }); } }); From 9c0af2be47da79c5e72182421d9e68f7d0d39c28 Mon Sep 17 00:00:00 2001 From: sam detweiler Date: Fri, 12 Dec 2025 12:42:11 -0600 Subject: [PATCH 2/2] fix comment --- modules/default/calendar/calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 824e31491c..51270497df 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -184,9 +184,9 @@ Module.register("calendar", { if (notification === "CALENDAR_EVENTS") { if (this.hasCalendarURL(payload.url)) { - // have we received data for this url + // have we received events for this url if (!this.calendarData[payload.url]) { - // no,m setup tehe structure + // no, setup the structure to hold the info this.calendarData[payload.url] = { events: null, checksum: null }; } // save the event list