Skip to content

Commit 79afa6c

Browse files
feat: add support for excluded events, hide duplicates option and broadcastPastEvents
1 parent 9e6119e commit 79afa6c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

MMM-GoogleCalendar.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Module.register("MMM-GoogleCalendar", {
3636
hidePrivate: false,
3737
hideOngoing: false,
3838
hideTime: false,
39+
hideDuplicates: false,
3940
colored: false,
4041
coloredSymbolOnly: false,
4142
customEvents: [], // Array of {keyword: "", symbol: "", color: ""} where Keyword is a regexp and symbol/color are to be applied for matched
@@ -366,7 +367,7 @@ Module.register("MMM-GoogleCalendar", {
366367
if (this.config.showEnd) {
367368
timeWrapper.innerHTML += ` - ${this.capFirst(moment(event.endDate, "x").format("LT"))}`;
368369
}
369-
370+
370371
eventWrapper.appendChild(timeWrapper);
371372
titleWrapper.classList.add("align-right");
372373
}
@@ -527,8 +528,10 @@ Module.register("MMM-GoogleCalendar", {
527528
}
528529

529530
const calendarConfig = {
530-
maximumEntries: calendar.maximumEntries,
531-
maximumNumberOfDays: calendar.maximumNumberOfDays
531+
maximumEntries: calendar.maximumEntries,
532+
maximumNumberOfDays: calendar.maximumNumberOfDays,
533+
broadcastPastEvents: calendar.broadcastPastEvents,
534+
excludedEvents: calendar.excludedEvents,
532535
};
533536

534537
if (
@@ -625,6 +628,11 @@ Module.register("MMM-GoogleCalendar", {
625628
for (const e in calendar) {
626629
const event = JSON.parse(JSON.stringify(calendar[e])); // clone object
627630

631+
// check if event is to be excluded
632+
if (this.config.excludedEvents.includes(event.summary)) {
633+
continue;
634+
}
635+
628636
// added props
629637
event.calendarID = calendarID;
630638
event.endDate = this.extractCalendarDate(event.end);
@@ -644,7 +652,7 @@ Module.register("MMM-GoogleCalendar", {
644652
continue;
645653
}
646654
}
647-
if (this.listContainsEvent(events, event)) {
655+
if (this.config.hideDuplicates && this.listContainsEvent(events, event)) {
648656
continue;
649657
}
650658
event.url = event.htmlLink;

node_helper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,13 @@ module.exports = NodeHelper.create({
240240
});
241241
} else {
242242
const events = res.data.items;
243+
243244
Log.info(
244245
`${this.name}: ${events.length} events loaded for ${calendarID}`
245246
);
246-
this.broadcastEvents(events, identifier, calendarID);
247+
this.broadcastEvents(events, identifier, calendarID);
247248
}
248-
249+
249250
this.scheduleNextCalendarFetch(
250251
calendarID,
251252
fetchInterval,

0 commit comments

Comments
 (0)