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) - Set Timezone `Europe/Berlin` in unit tests (needed for new formatTime tests)
- Added no-param-reassign eslint rule and fix warnings - Added no-param-reassign eslint rule and fix warnings
- updatenotification: Added `sendUpdatesNotifications` feature. Broadcast update with `UPDATES` notification to other modules - updatenotification: Added `sendUpdatesNotifications` feature. Broadcast update with `UPDATES` notification to other modules
- updatenotification: allow force scanning with `SCAN_UPDATES` notification from other modules
### Removed ### Removed

View File

@ -25,15 +25,25 @@ module.exports = NodeHelper.create({
}, },
async socketNotificationReceived(notification, payload) { async socketNotificationReceived(notification, payload) {
if (notification === "CONFIG") { switch (notification) {
this.config = payload; case "CONFIG":
} else if (notification === "MODULES") { this.config = payload;
// if this is the 1st time thru the update check process break;
if (!this.updateProcessStarted) { case "MODULES":
this.updateProcessStarted = true; // if this is the 1st time thru the update check process
await this.configureModules(payload); if (!this.updateProcessStarted) {
await this.performFetch(); 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) { notificationReceived(notification) {
if (notification === "DOM_OBJECTS_CREATED") { switch (notification) {
this.sendSocketNotification("CONFIG", this.config); case "DOM_OBJECTS_CREATED":
this.sendSocketNotification("MODULES", Object.keys(Module.definitions)); this.sendSocketNotification("CONFIG", this.config);
this.sendSocketNotification("MODULES", Object.keys(Module.definitions));
break;
case "SCAN_UPDATES":
this.sendSocketNotification("SCAN_UPDATES");
break;
} }
}, },