Skip to content

Commit c8e1957

Browse files
authored
Merge branch 'develop' into socketio_timeout
2 parents 356b337 + 3387bf8 commit c8e1957

6 files changed

Lines changed: 415 additions & 364 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Thanks to: @dathbe.
2626
- [tests] refactor: extract constants for weather electron tests (#3845)
2727
- [tests] refactor: add `setupDOMEnvironment` helper function to eliminate repetitive JSDOM setup code (#3860)
2828
- [tests] replace `console` with `Log` in calendar `debug.js` to avoid exception in eslint config (#3846)
29-
- [tests] speed up e2e tests, cleanup and stabilize weather e2e tests (#3847, #3848)
29+
- [tests] speed up e2e tests, cleanup and stabilize weather e2e tests, update snapshot url (#3847, #3848, #3861)
3030

3131
### Updated
3232

@@ -37,6 +37,8 @@ Thanks to: @dathbe.
3737
- [calendar] Fixed broken unittest that only broke on the 1st of July and 1st of january (#3830)
3838
- [clock] Fixed missing icons when no other modules with icons is loaded (#3834)
3939
- [weather] Fixed handling of empty values in weathergov providers handling of precipitationAmount (#3859)
40+
- [calendar] Fix regression handling of limit days (#3840)
41+
- [calendar] Fixed regression of calendarfetcherutils.shouldEventBeExcluded (#3841)
4042
- [core] Fixed socket.io timeout when server is slow to send notification, notification lost at client (#3380)
4143

4244
## [2.32.0] - 2025-07-01

modules/default/calendar/calendar.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -705,30 +705,24 @@ Module.register("calendar", {
705705
* Limit the number of days displayed
706706
* If limitDays is set > 0, limit display to that number of days
707707
*/
708-
if (this.config.limitDays > 0) {
709-
let newEvents = [];
710-
let lastDate = today.clone().subtract(1, "days");
711-
let days = 0;
712-
for (const ev of events) {
713-
let eventDate = this.timestampToMoment(ev.startDate);
714-
715-
/*
716-
* if date of event is later than lastdate
717-
* check if we already are showing max unique days
718-
*/
719-
if (eventDate.isAfter(lastDate)) {
720-
// if the only entry in the first day is a full day event that day is not counted as unique
721-
if (!this.config.limitDaysNeverSkip && newEvents.length === 1 && days === 1 && newEvents[0].fullDayEvent) {
722-
days--;
723-
}
724-
days++;
725-
if (days > this.config.limitDays) {
726-
continue;
727-
} else {
728-
lastDate = eventDate;
729-
}
708+
if (this.config.limitDays > 0 && events.length > 0) { // watch out for initial display before events arrive from helper
709+
// Group all events by date, events on the same date will be in a list with the key being the date.
710+
const eventsByDate = Object.groupBy(events, (ev) => this.timestampToMoment(ev.startDate).format("YYYY-MM-DD"));
711+
const newEvents = [];
712+
let currentDate = moment();
713+
let daysCollected = 0;
714+
715+
while (daysCollected < this.config.limitDays) {
716+
const dateStr = currentDate.format("YYYY-MM-DD");
717+
// Check if there are events on the currentDate
718+
if (eventsByDate[dateStr] && eventsByDate[dateStr].length > 0) {
719+
// If there are any events today then get all those events and select the currently active events and the events that are starting later in the day.
720+
newEvents.push(...eventsByDate[dateStr].filter((ev) => this.timestampToMoment(ev.endDate).isAfter(moment())));
721+
// Since we found a day with events, increase the daysCollected by 1
722+
daysCollected++;
730723
}
731-
newEvents.push(ev);
724+
// Search for the next day
725+
currentDate.add(1, "day");
732726
}
733727
events = newEvents;
734728
}

modules/default/calendar/calendarfetcherutils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const CalendarFetcherUtils = {
1616
* until: the date until the event should be excluded.
1717
*/
1818
shouldEventBeExcluded (config, title) {
19-
let filter = {
19+
let result = {
2020
excluded: false,
2121
until: null
2222
};
@@ -55,14 +55,14 @@ const CalendarFetcherUtils = {
5555

5656
if (CalendarFetcherUtils.titleFilterApplies(testTitle, filter, useRegex, regexFlags)) {
5757
if (until) {
58-
filter.until = until;
58+
result.until = until;
5959
} else {
60-
filter.excluded = true;
60+
result.excluded = true;
6161
}
6262
break;
6363
}
6464
}
65-
return filter;
65+
return result;
6666
},
6767

6868
/**

0 commit comments

Comments
 (0)