]> git.wh0rd.org Git - tt-rss.git/commitdiff
auto-catchup fully visible articles in the buffer when switching away from already...
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 26 Nov 2011 19:19:04 +0000 (23:19 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 26 Nov 2011 19:19:04 +0000 (23:19 +0400)
feedlist.js

index 833fe9e26ae4173525249a7c6c78eb277b5cae46..4f1a56c2a4e95cdcef696fea5dd95452682e0ec5 100644 (file)
@@ -64,11 +64,42 @@ function viewfeed(feed, subop, is_cat, offset, background, infscrol_req) {
 
                var cached_headlines = false;
 
-               if (feed == getActiveFeedId())
+               if (feed == getActiveFeedId()) {
                        cache_delete("feed:" + feed + ":" + is_cat);
-               else
+               } else {
                        cached_headlines = cache_get("feed:" + feed + ":" + is_cat);
 
+                       // switching to a different feed, we might as well catchup stuff visible
+                       // in headlines buffer (if any)
+                       if (!background && getInitParam("cdm_auto_catchup") == 1 && parseInt(getActiveFeedId()) > 0) {
+
+                               $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
+                                       function(child) {
+                                               var hf = $("headlines-frame");
+
+                                               if (hf.scrollTop + hf.offsetHeight >=
+                                                               child.offsetTop + child.offsetHeight) {
+
+                                                       var id = child.id.replace("RROW-", "");
+
+                                                       if (catchup_id_batch.indexOf(id) == -1)
+                                                               catchup_id_batch.push(id);
+
+                                               }
+
+                                               if (catchup_id_batch.length > 0) {
+                                                       window.clearTimeout(catchup_timeout_id);
+
+                                                       if (!_infscroll_request_sent) {
+                                                               catchup_timeout_id = window.setTimeout('catchupBatchedArticles()',
+                                                                       2000);
+                                                       }
+                                               }
+
+                                       });
+                       }
+               }
+
                if (offset == 0)
                        dijit.byId("content-tabs").selectChild(
                                dijit.byId("content-tabs").getChildren()[0]);