]> git.wh0rd.org Git - tt-rss.git/commitdiff
view: request counters in background, request_counters(): add client rate limit
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 20 May 2008 15:59:42 +0000 (16:59 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 20 May 2008 15:59:42 +0000 (16:59 +0100)
backend.php
feedlist.js
viewfeed.js

index ba7cbdb0b33326f4063d915196fdb1d550a94d23..94a63dae13a30f98abcd9292288f614f3ec545e7 100644 (file)
                                }
                        }
 
-                       if ($mode != "prefetch_old") {
+/*                     if ($mode != "prefetch_old") {
                                print "<counters>";
                                getAllCounters($link, $omode);
                                print "</counters>";
-                       }
+                       } */
 
                        print "</reply>";
                break; // view
index df30a6107b213ffbb85e74aa5e93506039b8f5bc..b4a0e8832d21abbdde4962275587221c61890bb1 100644 (file)
@@ -496,7 +496,7 @@ function mouse_up_handler(e) {
        }
 }
 
-function request_counters() {
+function request_counters_real() {
 
        try {
                var query = "backend.php?op=rpc&subop=getAllCounters";
@@ -516,6 +516,28 @@ function request_counters() {
                                }
                        } });
 
+       } catch (e) {
+               exception_error("request_counters_real", e);
+       }
+}
+
+var counters_last_request = 0;
+
+function request_counters() {
+
+       try {
+
+               var date = new Date();
+               var timestamp = Math.round(date.getTime() / 1000);
+
+               if (timestamp - counters_last_request > 10) {
+                       debug("scheduling request of counters...");
+                       window.setTimeout("request_counters_real()", 100);
+                       counters_last_request = timestamp;
+               } else {
+                       debug("request_counters: rate limit reached: " + (timestamp - counters_last_request));
+               }
+
        } catch (e) {
                exception_error("request_counters", e);
        }
index 16f96216a4fefded7f1fcd1b4661b5623507d14b..bd548ced9b0b77c8496d421a66a7b9414b0b5b89 100644 (file)
@@ -325,7 +325,7 @@ function article_callback2(transport, id, feed_id) {
                        active_real_feed_id = feed_id;
                        active_post_id = id; 
 
-                       //showArticleInHeadlines(id);   
+                       showArticleInHeadlines(id);     
 
                        var reply = transport.responseXML.firstChild.firstChild;
 
@@ -367,7 +367,8 @@ function article_callback2(transport, id, feed_id) {
                                debug("parsing piggybacked counters: " + counters);
                                parse_counters(counters, false);
                        } else {
-                               debug("counters container not found in reply");
+                               debug("counters container not found in reply, requesting...");
+                               request_counters();
                        }
                }
 
@@ -426,8 +427,6 @@ function view(id, feed_id, skip_history) {
                var crow = document.getElementById("RROW-" + id);
                var article_is_unread = crow.className.match("Unread");
 
-               showArticleInHeadlines(id);
-
                if (!cached_article) {
 
                        notify_progress("Loading, please wait...");
@@ -442,6 +441,8 @@ function view(id, feed_id, skip_history) {
 
                        query = query + "&mode=prefetch_old";
                        render_article(cached_article);
+                       showArticleInHeadlines(id);
+
                }
 
                cache_expire();