mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
45 lines
840 B
JavaScript
45 lines
840 B
JavaScript
|
var simpleGit = require("simple-git")(__dirname + "/../..");
|
||
|
var NodeHelper = require("node_helper");
|
||
|
|
||
|
module.exports = NodeHelper.create({
|
||
|
|
||
|
config: {},
|
||
|
|
||
|
updateTimer: null,
|
||
|
|
||
|
start: function () {
|
||
|
|
||
|
},
|
||
|
|
||
|
socketNotificationReceived: function (notification, payload) {
|
||
|
if (notification === "CONFIG") {
|
||
|
this.config = payload;
|
||
|
this.preformFetch();
|
||
|
}
|
||
|
},
|
||
|
|
||
|
preformFetch() {
|
||
|
var self = this;
|
||
|
simpleGit.fetch().status(function(err, data) {
|
||
|
if (!err) {
|
||
|
self.sendSocketNotification("STATUS", data);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
this.scheduleNextFetch(this.config.updateInterval);
|
||
|
},
|
||
|
|
||
|
scheduleNextFetch: function(delay) {
|
||
|
if (delay < 60 * 1000) {
|
||
|
delay = 60 * 1000
|
||
|
}
|
||
|
|
||
|
console.log(delay);
|
||
|
var self = this;
|
||
|
clearTimeout(this.updateTimer);
|
||
|
this.updateTimer = setTimeout(function() {
|
||
|
self.preformFetch();
|
||
|
}, delay);
|
||
|
}
|
||
|
|
||
|
});
|