Remote force check update (#3127)

updatenotification: 

allow force scanning with `SCAN_UPDATES` notification from other modules
This commit is contained in:
Bugsounet - Cédric 2023-06-18 14:33:03 +02:00 committed by GitHub
parent e985e99036
commit c1850f2577
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 12 deletions

View File

@ -16,6 +16,7 @@ _This release is scheduled to be released on 2023-07-01._
- Set Timezone `Europe/Berlin` in unit tests (needed for new formatTime tests)
- Added no-param-reassign eslint rule and fix warnings
- updatenotification: Added `sendUpdatesNotifications` feature. Broadcast update with `UPDATES` notification to other modules
- updatenotification: allow force scanning with `SCAN_UPDATES` notification from other modules
### Removed

View File

@ -25,15 +25,25 @@ module.exports = NodeHelper.create({
},
async socketNotificationReceived(notification, payload) {
if (notification === "CONFIG") {
this.config = payload;
} else if (notification === "MODULES") {
// if this is the 1st time thru the update check process
if (!this.updateProcessStarted) {
this.updateProcessStarted = true;
await this.configureModules(payload);
await this.performFetch();
}
switch (notification) {
case "CONFIG":
this.config = payload;
break;
case "MODULES":
// if this is the 1st time thru the update check process
if (!this.updateProcessStarted) {
this.updateProcessStarted = true;
await this.configureModules(payload);
await this.performFetch();
}
break;
case "SCAN_UPDATES":
// 1st time of check allows to force new scan
if (this.updateProcessStarted) {
clearTimeout(this.updateTimer);
await this.performFetch();
}
break;
}
},

View File

@ -34,9 +34,14 @@ Module.register("updatenotification", {
},
notificationReceived(notification) {
if (notification === "DOM_OBJECTS_CREATED") {
this.sendSocketNotification("CONFIG", this.config);
this.sendSocketNotification("MODULES", Object.keys(Module.definitions));
switch (notification) {
case "DOM_OBJECTS_CREATED":
this.sendSocketNotification("CONFIG", this.config);
this.sendSocketNotification("MODULES", Object.keys(Module.definitions));
break;
case "SCAN_UPDATES":
this.sendSocketNotification("SCAN_UPDATES");
break;
}
},