mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-09-02 03:02:19 +00:00
Fix limitdays regression (#3863)
fixes #3840 this is a rewrite --------- Co-authored-by: veeck <gitkraken@veeck.de>
This commit is contained in:
@@ -37,6 +37,7 @@ Thanks to: @dathbe.
|
||||
- [calendar] Fixed broken unittest that only broke on the 1st of July and 1st of january (#3830)
|
||||
- [clock] Fixed missing icons when no other modules with icons is loaded (#3834)
|
||||
- [weather] Fixed handling of empty values in weathergov providers handling of precipitationAmount (#3859)
|
||||
- [calendar] Fix regression handling of limit days (#3840)
|
||||
|
||||
## [2.32.0] - 2025-07-01
|
||||
|
||||
|
@@ -705,30 +705,24 @@ Module.register("calendar", {
|
||||
* Limit the number of days displayed
|
||||
* If limitDays is set > 0, limit display to that number of days
|
||||
*/
|
||||
if (this.config.limitDays > 0) {
|
||||
let newEvents = [];
|
||||
let lastDate = today.clone().subtract(1, "days");
|
||||
let days = 0;
|
||||
for (const ev of events) {
|
||||
let eventDate = this.timestampToMoment(ev.startDate);
|
||||
if (this.config.limitDays > 0 && events.length > 0) { // watch out for initial display before events arrive from helper
|
||||
// Group all events by date, events on the same date will be in a list with the key being the date.
|
||||
const eventsByDate = Object.groupBy(events, (ev) => this.timestampToMoment(ev.startDate).format("YYYY-MM-DD"));
|
||||
const newEvents = [];
|
||||
let currentDate = moment();
|
||||
let daysCollected = 0;
|
||||
|
||||
/*
|
||||
* if date of event is later than lastdate
|
||||
* check if we already are showing max unique days
|
||||
*/
|
||||
if (eventDate.isAfter(lastDate)) {
|
||||
// if the only entry in the first day is a full day event that day is not counted as unique
|
||||
if (!this.config.limitDaysNeverSkip && newEvents.length === 1 && days === 1 && newEvents[0].fullDayEvent) {
|
||||
days--;
|
||||
while (daysCollected < this.config.limitDays) {
|
||||
const dateStr = currentDate.format("YYYY-MM-DD");
|
||||
// Check if there are events on the currentDate
|
||||
if (eventsByDate[dateStr] && eventsByDate[dateStr].length > 0) {
|
||||
// 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.
|
||||
newEvents.push(...eventsByDate[dateStr].filter((ev) => this.timestampToMoment(ev.endDate).isAfter(moment())));
|
||||
// Since we found a day with events, increase the daysCollected by 1
|
||||
daysCollected++;
|
||||
}
|
||||
days++;
|
||||
if (days > this.config.limitDays) {
|
||||
continue;
|
||||
} else {
|
||||
lastDate = eventDate;
|
||||
}
|
||||
}
|
||||
newEvents.push(ev);
|
||||
// Search for the next day
|
||||
currentDate.add(1, "day");
|
||||
}
|
||||
events = newEvents;
|
||||
}
|
||||
|
707
package-lock.json
generated
707
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@@ -77,13 +77,13 @@
|
||||
"console-stamp": "^3.1.2",
|
||||
"croner": "^9.1.0",
|
||||
"envsub": "^4.1.0",
|
||||
"eslint": "^9.33.0",
|
||||
"eslint": "^9.34.0",
|
||||
"express": "^5.1.0",
|
||||
"express-ipfilter": "^1.3.2",
|
||||
"feedme": "^2.0.2",
|
||||
"helmet": "^8.1.0",
|
||||
"html-to-text": "^9.0.5",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"iconv-lite": "^0.7.0",
|
||||
"module-alias": "^2.2.3",
|
||||
"moment": "^2.30.1",
|
||||
"moment-timezone": "^0.6.0",
|
||||
@@ -92,8 +92,8 @@
|
||||
"pm2": "^6.0.8",
|
||||
"socket.io": "^4.8.1",
|
||||
"suncalc": "^1.9.0",
|
||||
"systeminformation": "^5.27.7",
|
||||
"undici": "^7.13.0",
|
||||
"systeminformation": "^5.27.8",
|
||||
"undici": "^7.15.0",
|
||||
"weathericons": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -101,15 +101,15 @@
|
||||
"cspell": "^9.2.0",
|
||||
"eslint-plugin-import-x": "^4.16.1",
|
||||
"eslint-plugin-jest": "^29.0.1",
|
||||
"eslint-plugin-jsdoc": "^52.0.4",
|
||||
"eslint-plugin-package-json": "^0.52.1",
|
||||
"eslint-plugin-jsdoc": "^54.1.1",
|
||||
"eslint-plugin-package-json": "^0.56.0",
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"husky": "^9.1.7",
|
||||
"jest": "^30.0.5",
|
||||
"jest": "^30.1.1",
|
||||
"jsdom": "^26.1.0",
|
||||
"lint-staged": "^16.1.5",
|
||||
"markdownlint-cli2": "^0.18.1",
|
||||
"playwright": "^1.54.2",
|
||||
"playwright": "^1.55.0",
|
||||
"prettier": "^3.6.2",
|
||||
"sinon": "^21.0.0",
|
||||
"stylelint": "^16.23.1",
|
||||
@@ -117,7 +117,7 @@
|
||||
"stylelint-prettier": "^5.0.3"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron": "^37.2.6"
|
||||
"electron": "^37.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.14.0"
|
||||
|
Reference in New Issue
Block a user