use batch-based catching up in cdmExpandArticle() to reduce server load
This commit is contained in:
parent
eaec06f950
commit
176a489e54
|
@ -568,7 +568,7 @@ function moveToPost(mode, noscroll, noexpand) {
|
||||||
console.log("cur: " + getActiveArticleId() + " next: " + next_id);
|
console.log("cur: " + getActiveArticleId() + " next: " + next_id);
|
||||||
|
|
||||||
if (mode == "next") {
|
if (mode == "next") {
|
||||||
if (next_id /*|| getActiveArticleId()*/) {
|
if (next_id || getActiveArticleId()) {
|
||||||
if (isCdmMode()) {
|
if (isCdmMode()) {
|
||||||
|
|
||||||
var article = $("RROW-" + getActiveArticleId());
|
var article = $("RROW-" + getActiveArticleId());
|
||||||
|
@ -1305,6 +1305,8 @@ function headlines_scroll_handler(e) {
|
||||||
updateFloatingTitle();
|
updateFloatingTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catchupCurrentBatchIfNeeded();
|
||||||
|
|
||||||
if (getInitParam("cdm_auto_catchup") == 1) {
|
if (getInitParam("cdm_auto_catchup") == 1) {
|
||||||
|
|
||||||
// let's get DOM some time to settle down
|
// let's get DOM some time to settle down
|
||||||
|
@ -1326,16 +1328,6 @@ function headlines_scroll_handler(e) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (catchup_id_batch.length > 0) {
|
|
||||||
window.clearTimeout(catchup_timeout_id);
|
|
||||||
|
|
||||||
catchup_timeout_id = window.setTimeout('catchupBatchedArticles()', 500);
|
|
||||||
|
|
||||||
if (catchup_id_batch.length >= 10) {
|
|
||||||
catchupBatchedArticles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_infscroll_disable) {
|
if (_infscroll_disable) {
|
||||||
var child = $$("#headlines-frame div[id*=RROW]").last();
|
var child = $$("#headlines-frame div[id*=RROW]").last();
|
||||||
|
|
||||||
|
@ -1370,6 +1362,8 @@ function catchupBatchedArticles() {
|
||||||
try {
|
try {
|
||||||
if (catchup_id_batch.length > 0 && !_infscroll_request_sent && !_catchup_request_sent) {
|
if (catchup_id_batch.length > 0 && !_infscroll_request_sent && !_catchup_request_sent) {
|
||||||
|
|
||||||
|
console.log("catchupBatchedArticles: working");
|
||||||
|
|
||||||
// make a copy of the array
|
// make a copy of the array
|
||||||
var batch = catchup_id_batch.slice();
|
var batch = catchup_id_batch.slice();
|
||||||
var query = "?op=rpc&method=catchupSelected" +
|
var query = "?op=rpc&method=catchupSelected" +
|
||||||
|
@ -1573,8 +1567,12 @@ function cdmExpandArticle(id, noexpand) {
|
||||||
if (old_offset > new_offset)
|
if (old_offset > new_offset)
|
||||||
$("headlines-frame").scrollTop -= (old_offset-new_offset);
|
$("headlines-frame").scrollTop -= (old_offset-new_offset);
|
||||||
|
|
||||||
if (!noexpand)
|
if (!noexpand) {
|
||||||
toggleUnread(id, 0, true);
|
if (catchup_id_batch.indexOf(id) == -1)
|
||||||
|
catchup_id_batch.push(id);
|
||||||
|
|
||||||
|
catchupCurrentBatchIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
toggleSelected(id);
|
toggleSelected(id);
|
||||||
$("RROW-" + id).addClassName("active");
|
$("RROW-" + id).addClassName("active");
|
||||||
|
@ -2430,6 +2428,17 @@ function updateFloatingTitle(unread_only) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function catchupCurrentBatchIfNeeded() {
|
||||||
|
if (catchup_id_batch.length > 0) {
|
||||||
|
window.clearTimeout(catchup_timeout_id);
|
||||||
|
catchup_timeout_id = window.setTimeout('catchupBatchedArticles()', 1000);
|
||||||
|
|
||||||
|
if (catchup_id_batch.length >= 10) {
|
||||||
|
catchupBatchedArticles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function cdmFooterClick(event) {
|
function cdmFooterClick(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
Loading…
Reference in New Issue