From dfd071e28de7c5637ce487445d10fc0b3fdc3601 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 4 Apr 2013 09:37:43 +0400 Subject: add experimental cooldown after headlines buffer had been manipulated before auto catchup is enabled only unmark articles which had been processed when automarking --- js/viewfeed.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/viewfeed.js b/js/viewfeed.js index c1163eab7..3d23e4c06 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -12,6 +12,7 @@ var catchup_timeout_id = false; var cids_requested = []; var loaded_article_ids = []; +var _last_headlines_update = 0; var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null; @@ -204,6 +205,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) { } _infscroll_request_sent = 0; + _last_headlines_update = new Date().getTime() / 1000; unpackVisibleHeadlines(); @@ -1159,7 +1161,6 @@ function postMouseOut(id) { function unpackVisibleHeadlines() { try { - if (!isCdmMode()) return; $$("#headlines-frame > div[id*=RROW]").each( @@ -1178,7 +1179,6 @@ function unpackVisibleHeadlines() { } ); - } catch (e) { exception_error("unpackVisibleHeadlines", e); } @@ -1209,6 +1209,11 @@ function headlines_scroll_handler(e) { if (getInitParam("cdm_auto_catchup") == 1) { + // let's get DOM some time to settle down + var ts = new Date().getTime() / 1000; + + if (ts - _last_headlines_update < 3) return; + $$("#headlines-frame > div[id*=RROW][class*=Unread]").each( function(child) { if (child.hasClassName("Unread") && $("headlines-frame").scrollTop > -- cgit v1.2.3-54-g00ecf From ae31704bb3dfc55b960f58551fdf7367959a3f54 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 4 Apr 2013 09:49:37 +0400 Subject: only unmark articles which had been processed when automarking (for realz) --- classes/rpc.php | 2 +- js/viewfeed.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/classes/rpc.php b/classes/rpc.php index a63392095..508dd8d41 100644 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -310,7 +310,7 @@ class RPC extends Handler_Protected { catchupArticlesById($this->link, $ids, $cmode); - print json_encode(array("message" => "UPDATE_COUNTERS")); + print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids)); } function markSelected() { diff --git a/js/viewfeed.js b/js/viewfeed.js index 3d23e4c06..7813ab7ef 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -205,7 +205,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) { } _infscroll_request_sent = 0; - _last_headlines_update = new Date().getTime() / 1000; + _last_headlines_update = new Date().getTime(); unpackVisibleHeadlines(); @@ -1210,9 +1210,8 @@ function headlines_scroll_handler(e) { if (getInitParam("cdm_auto_catchup") == 1) { // let's get DOM some time to settle down - var ts = new Date().getTime() / 1000; - - if (ts - _last_headlines_update < 3) return; + var ts = new Date().getTime(); + if (ts - _last_headlines_update < 100) return; $$("#headlines-frame > div[id*=RROW][class*=Unread]").each( function(child) { @@ -1259,7 +1258,11 @@ function catchupBatchedArticles() { onComplete: function(transport) { handle_rpc_json(transport); + reply = JSON.parse(transport.responseText); + var batch = reply.ids; + batch.each(function(id) { + console.log(id); var elem = $("RROW-" + id); if (elem) elem.removeClassName("Unread"); catchup_id_batch.remove(id); -- cgit v1.2.3-54-g00ecf