From a36856c552dca0df8d57b5278f742b93c2604aa0 Mon Sep 17 00:00:00 2001 From: Samed Ozdemir <5721836+xsorifc28@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:07:50 -0400 Subject: [PATCH 1/4] feat(compliments): add configuration for refreshing remote file periodically --- modules/default/compliments/compliments.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 4c4bef471f..3813fb40e6 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -12,6 +12,7 @@ Module.register("compliments", { }, updateInterval: 30000, remoteFile: null, + remoteFileRefreshPeriod: null, fadeSpeed: 4000, morningStartTime: 3, morningEndTime: 12, @@ -41,6 +42,12 @@ Module.register("compliments", { const response = await this.loadComplimentFile(); this.config.compliments = JSON.parse(response); this.updateDom(); + if (this.removeFileRefreshPeriod != null) { + this.remoteFileRefreshFunc = setInterval(() => { + const response = await this.loadComplimentFile(); + this.config.compliments = JSON.parse(response); + }, this.remoteFileRefreshPeriod) + } } let minute_sync_delay = 1; // loop thru all the configured when events From a7f83034bdf2830941c670ed0a6091293f367484 Mon Sep 17 00:00:00 2001 From: Samed Ozdemir <5721836+xsorifc28@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:11:38 -0400 Subject: [PATCH 2/4] Update compliments.js --- modules/default/compliments/compliments.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 3813fb40e6..d5ecacffc9 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -12,7 +12,7 @@ Module.register("compliments", { }, updateInterval: 30000, remoteFile: null, - remoteFileRefreshPeriod: null, + remoteFileRefreshInterval: null, fadeSpeed: 4000, morningStartTime: 3, morningEndTime: 12, @@ -42,11 +42,11 @@ Module.register("compliments", { const response = await this.loadComplimentFile(); this.config.compliments = JSON.parse(response); this.updateDom(); - if (this.removeFileRefreshPeriod != null) { + if (this.remoteFileRefreshInterval != null) { this.remoteFileRefreshFunc = setInterval(() => { const response = await this.loadComplimentFile(); this.config.compliments = JSON.parse(response); - }, this.remoteFileRefreshPeriod) + }, this.remoteFileRefreshInterval) } } let minute_sync_delay = 1; From aa9e08331952ba0b1a1ee49aa72f719bd266f285 Mon Sep 17 00:00:00 2001 From: Samed Ozdemir <5721836+xsorifc28@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:14:13 -0400 Subject: [PATCH 3/4] Update compliments.js --- modules/default/compliments/compliments.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index d5ecacffc9..90c17d37a7 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -42,11 +42,12 @@ Module.register("compliments", { const response = await this.loadComplimentFile(); this.config.compliments = JSON.parse(response); this.updateDom(); - if (this.remoteFileRefreshInterval != null) { + if (this.config.remoteFileRefreshInterval != null) { this.remoteFileRefreshFunc = setInterval(() => { const response = await this.loadComplimentFile(); this.config.compliments = JSON.parse(response); - }, this.remoteFileRefreshInterval) + this.lastIndexUsed = -1; + }, this.config.remoteFileRefreshInterval) } } let minute_sync_delay = 1; From e46bdbd3ca2527bc13dc37fe6fffb7a0719489c6 Mon Sep 17 00:00:00 2001 From: Samed Ozdemir <5721836+xsorifc28@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:23:34 -0400 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3158a93016..8b4e635ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ Thanks to: @bugsounet, @dkallen78, @jargordon, @khassel, @KristjanESPERANTO, @Ma ### Added +- [compliments] Added config for refreshing the remote file on an interval (default - no refresh) - [compliments] Added support for cron type date/time format entries mm hh DD MM dow (minutes/hours/days/months and day of week) see https://crontab.cronhub.io for construction (#3481) - [core] Check config at every start of MagicMirror² (#3450) - [core] Add spelling check (cspell): `npm run test:spelling` and handle spelling issues (#3544)