From e163fe40f592643693cb54c09e416acd286c3cc0 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Tue, 13 Sep 2016 23:14:30 +0200 Subject: Make refresh persist timeout cache global --- modules/changes/changes.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules/changes') 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)); } -- cgit v1.2.3-70-g09d2