Update compliments module (#3471)

`Fixes #3465`

Add config option `specialDayUnique` that defaults to `false` and causes
special day compliments to be added to the existing compliments array.
Setting this option to `true` will only show the compliments that have
been configured for that day.

---------

Co-authored-by: Veeck <github@veeck.de>
Co-authored-by: veeck <michael.veeck@nebenan.de>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
This commit is contained in:
WallysWellies
2024-06-24 21:40:59 +01:00
committed by GitHub
parent 3d9d72e64e
commit aefb3a0b6d
5 changed files with 75 additions and 1 deletions

View File

@@ -15,7 +15,8 @@ Module.register("compliments", {
morningEndTime: 12,
afternoonStartTime: 12,
afternoonEndTime: 17,
random: true
random: true,
specialDayUnique: false
},
lastIndexUsed: -1,
// Set currentweather from module
@@ -98,6 +99,10 @@ Module.register("compliments", {
// Add compliments for special days
for (let entry in this.config.compliments) {
if (new RegExp(entry).test(date)) {
// Only display compliments configured for the day if specialDayUnique is set to true
if (this.config.specialDayUnique) {
compliments.length = 0;
}
Array.prototype.push.apply(compliments, this.config.compliments[entry]);
}
}