From c925e8847522e0f122778fac82b3b4fca5d49bf7 Mon Sep 17 00:00:00 2001 From: buxxi Date: Tue, 11 Feb 2020 18:13:39 +0100 Subject: [PATCH] Adding support for ignoring update check for certain modules --- CHANGELOG.md | 1 + .../default/updatenotification/node_helper.js | 27 ++++++++++++++----- .../updatenotification/updatenotification.js | 1 + 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0debd80f..c9bf13c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - The `clock` module now optionally displays sun and moon data, including rise/set times, remaining daylight, and percent of moon illumination. - Added Hebrew translation. - Add HTTPS support and update config.js.sample +- Added the ability to configure a list of modules that shouldn't be update checked. ### Fixed diff --git a/modules/default/updatenotification/node_helper.js b/modules/default/updatenotification/node_helper.js index 03ecd745..818697c0 100644 --- a/modules/default/updatenotification/node_helper.js +++ b/modules/default/updatenotification/node_helper.js @@ -22,7 +22,7 @@ module.exports = NodeHelper.create({ simpleGits.push({"module": "default", "git": SimpleGit(path.normalize(__dirname + "/../../../"))}); for (moduleName in modules) { - if (defaultModules.indexOf(moduleName) < 0) { + if (!this.ignoreUpdateChecking(moduleName)) { // Default modules are included in the main MagicMirror repo var moduleFolder = path.normalize(__dirname + "/../../" + moduleName); @@ -56,15 +56,15 @@ module.exports = NodeHelper.create({ this.config = payload; } else if(notification === "MODULES") { // if this is the 1st time thru the update check process - if(this.updateProcessStarted==false ){ - this.updateProcessStarted=true; + if (!this.updateProcessStarted) { + this.updateProcessStarted = true; this.configureModules(payload); - this.preformFetch(); + this.performFetch(); } } }, - preformFetch() { + performFetch() { var self = this; simpleGits.forEach(function(sg) { sg.git.fetch().status(function(err, data) { @@ -91,8 +91,23 @@ module.exports = NodeHelper.create({ var self = this; clearTimeout(this.updateTimer); this.updateTimer = setTimeout(function() { - self.preformFetch(); + self.performFetch(); }, delay); + }, + + ignoreUpdateChecking: function(moduleName) { + // Should not check for updates for default modules + if (defaultModules.indexOf(moduleName) >= 0) { + return true; + } + + // Should not check for updates for ignored modules + if (this.config.ignoreModules.indexOf(moduleName) >= 0) { + return true; + } + + // The rest of the modules that passes should check for updates + return false; } }); diff --git a/modules/default/updatenotification/updatenotification.js b/modules/default/updatenotification/updatenotification.js index d4bdc568..35a018bf 100644 --- a/modules/default/updatenotification/updatenotification.js +++ b/modules/default/updatenotification/updatenotification.js @@ -3,6 +3,7 @@ Module.register("updatenotification", { defaults: { updateInterval: 10 * 60 * 1000, // every 10 minutes refreshInterval: 24 * 60 * 60 * 1000, // one day + ignoreModules: [] }, suspended: false,