summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-11-09 09:39:26 +0100
committertomsmeding <tom.smeding@gmail.com>2016-11-09 09:39:26 +0100
commit7cacd9adc7f37377f55e095f743a0889ce0dd6db (patch)
tree7c3a585a3ed3693a97f3cbc491de39c6ed857762
parenta1876e03e0af0f6e3a0b9aadaa6412b801005f40 (diff)
changes: fix more email bugs
-rw-r--r--modules/changes/changes.js38
1 files changed, 20 insertions, 18 deletions
diff --git a/modules/changes/changes.js b/modules/changes/changes.js
index 4e9d87e..b420658 100644
--- a/modules/changes/changes.js
+++ b/modules/changes/changes.js
@@ -45,28 +45,26 @@ if(gsettings.notify){
scheduleNotify();
}
-var notifyIsScheduled=false;
+var notifyTimeout=null;
function scheduleNotify(){
- if(notifyIsScheduled){
+ if(notifyTimeout){
console.log("WARNING: requesting notify schedule when already scheduled");
return;
}
- notifyIsScheduled=true;
- var timeoutFunc=function(){
- if(!gsettings.notify){
- notifyIsScheduled=false;
- return;
- }
- performNotify(gsettings.notify,function(){
- performCleanup();
- if(gsettings.notify){
- setTimeout(timeoutFunc,gsettings.notify.interval);
- } else {
- notifyIsScheduled=false;
- }
- });
- };
- setTimeout(timeoutFunc,gsettings.notify.interval);
+ notifyTimeout=setTimeout(notifyTimerFunction,gsettings.notify.interval);
+}
+
+function notifyTimerFunction(){
+ if(!gsettings.notify){
+ notifyTimeout=null;
+ return;
+ }
+ notifyTimeout=setTimeout(notifyTimerFunction,gsettings.notify.interval);
+ console.log("Performing notify");
+ performNotify(gsettings.notify,function(){
+ console.log("Performing cleanup");
+ performCleanup();
+ });
}
@@ -228,8 +226,11 @@ function performNotify(settings,cb){
newdate: newhashes[url].date
});
}
+ console.log("performNotify: diffs = "+JSON.stringify(diffs));
if(diffs.length!=0){
sendMail(settings.to,constructMailBody(settings.to,diffs),cb);
+ } else {
+ cb();
}
});
}
@@ -266,6 +267,7 @@ function performCleanup(){
}
}
}
+ persist.setItemSync("urls",urls);
}