From 2779d19d5c75ff176c458634cf02a854882ea55b Mon Sep 17 00:00:00 2001 From: Johan Alvinger Date: Tue, 24 Nov 2020 23:06:41 +0100 Subject: [PATCH] All events from the beginning of today were fetched but we only want the ones that are ongoing or upcoming. --- modules/default/calendar/calendarfetcher.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/default/calendar/calendarfetcher.js b/modules/default/calendar/calendarfetcher.js index 7cb4434c..0fb13ca5 100644 --- a/modules/default/calendar/calendarfetcher.js +++ b/modules/default/calendar/calendarfetcher.js @@ -376,7 +376,17 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn return a.startDate - b.startDate; }); - events = newEvents.slice(0, maximumEntries); + if (includePastEvents) { + // Include all events + events = newEvents; + } else { + // All events from startOfToday are fetched but we only want the ones that haven't ended yet + const now = moment(); + for (ne of newEvents) { + if (moment(ne.endDate, "x").isAfter(now)) events.push(ne); + } + } + events = events.slice(0, maximumEntries); self.broadcastEvents(); scheduleTimer();