diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-09-13 23:14:30 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-09-13 23:14:30 +0200 |
commit | e163fe40f592643693cb54c09e416acd286c3cc0 (patch) | |
tree | b971efe5531dd39a2a831d1a894ec7b28004cea5 | |
parent | 2397b919064598e2c59dc997cf14add194687b54 (diff) |
Make refresh persist timeout cache global
-rw-r--r-- | modules/changes/changes.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modules/changes/changes.js b/modules/changes/changes.js index 9c536b3..c3f24af 100644 --- a/modules/changes/changes.js +++ b/modules/changes/changes.js @@ -81,11 +81,12 @@ function fetch(method,url,data/*?*/,cb){ req.end(); } +var refresh_persist_timeout=null; + function refreshURLs(){ var hashes={}; var i; var url; - var timeout=null; for(url in urls){ console.log("Fetching <"+url+">"); fetch("GET",url,function(url,status,body){ @@ -107,10 +108,11 @@ function refreshURLs(){ urls[url].timeline.push(hashes[url]); //} - if(timeout)clearTimeout(timeout); - timeout=setTimeout(function(){ + if(refresh_persist_timeout!=null)clearTimeout(refresh_persist_timeout); + refresh_persist_timeout=setTimeout(function(){ persist.setItemSync("urls",urls); console.log("(persisted after refresh)") + refresh_persist_timeout=null; },2000); }.bind(null,url)); } |