Broadcast all calendar events while still honoring global and per-calendar maximumEntries

This commit is contained in:
Jonathan Kolb 2022-07-02 21:08:43 -04:00
parent 5b1b25fa86
commit f1f2a61dc8
3 changed files with 17 additions and 2 deletions

View File

@ -15,6 +15,8 @@ _This release is scheduled to be released on 2022-10-01._
## Fixed
- Broadcast all calendar events while still honoring global and per-calendar maximumEntries.
## [2.20.0] - 2022-07-02
Special thanks to the following contributors: @eouia, @khassel, @kolbyjack, @KristjanESPERANTO, @nathannaveen, @naveensrinivasan, @rejas, @rohitdharavath and @sdetweil.

View File

@ -493,6 +493,7 @@ Module.register("calendar", {
for (const calendarUrl in this.calendarData) {
const calendar = this.calendarData[calendarUrl];
let remainingEntries = this.maximumEntriesForUrl(calendarUrl);
for (const e in calendar) {
const event = JSON.parse(JSON.stringify(calendar[e])); // clone object
@ -510,6 +511,9 @@ Module.register("calendar", {
if (this.listContainsEvent(events, event)) {
continue;
}
if (--remainingEntries < 0) {
break;
}
}
event.url = calendarUrl;
event.today = event.startDate >= today && event.startDate < today + 24 * 60 * 60 * 1000;
@ -718,6 +722,16 @@ Module.register("calendar", {
return this.getCalendarProperty(url, "repeatingCountTitle", this.config.defaultRepeatingCountTitle);
},
/**
* Retrieves the maximum entry count for a specific calendar url.
*
* @param {string} url The calendar url
* @returns {int} The maximum entry count
*/
maximumEntriesForUrl: function (url) {
return this.getCalendarProperty(url, "maximumEntries", this.config.maximumEntries);
},
/**
* Helper method to retrieve the property for a specific calendar url.
*

View File

@ -498,8 +498,7 @@ const CalendarUtils = {
return a.startDate - b.startDate;
});
let maxEvents = newEvents.slice(0, config.maximumEntries);
return maxEvents;
return newEvents;
},
/**