summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-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);
}