view: request counters in background, request_counters(): add client rate limit
This commit is contained in:
parent
5aaf9b34e4
commit
997d9d7cad
|
@ -210,11 +210,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ($mode != "prefetch_old") {
|
||||
/* if ($mode != "prefetch_old") {
|
||||
print "<counters>";
|
||||
getAllCounters($link, $omode);
|
||||
print "</counters>";
|
||||
}
|
||||
} */
|
||||
|
||||
print "</reply>";
|
||||
break; // view
|
||||
|
|
24
feedlist.js
24
feedlist.js
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue