remove headline precaching stuff, conflicts with dijit widgets in

headlines buffer
master
Andrew Dolgov 12 years ago
parent 524de8dcf6
commit 2bee32ffa7

@ -66,45 +66,8 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) {
last_requested_article = 0;
var cached_headlines = false;
if (feed == getActiveFeedId() && activeFeedIsCat() == is_cat) {
cache_delete("feed:" + feed + ":" + is_cat);
} else {
cached_headlines = cache_get("feed:" + feed + ":" + is_cat);
if (feed != getActiveFeedId() || activeFeedIsCat() != is_cat) {
if (!background && _search_query) _search_query = false;
// switching to a different feed, we might as well catchup stuff visible
// in headlines buffer (if any)
// disabled for now because this behavior is considered confusing -fox
/* if (!background && isCdmMode() && 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 (!background) {
@ -115,15 +78,6 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) {
_infscroll_disable = 0;
}
if (!offset && !method && cached_headlines && !background) {
try {
render_local_headlines(feed, is_cat, JSON.parse(cached_headlines));
return;
} catch (e) {
console.warn("render_local_headlines failed: " + e);
}
}
if (offset != 0 && !method) {
var timestamp = get_timestamp();
@ -214,7 +168,6 @@ function feedlist_init() {
request_counters(true);
timeout();
setTimeout("precache_headlines_idle()", 15000);
} catch (e) {
exception_error("feedlist/init", e);
@ -303,8 +256,6 @@ function parse_counters(elems, scheduled_call) {
if (getFeedUnread(id, (kind == "cat")) != ctr ||
(kind == "cat")) {
cache_delete("feed:" + id + ":" + (kind == "cat"));
}
setFeedUnread(id, (kind == "cat"), ctr);
@ -563,8 +514,6 @@ function decrementFeedCounter(feed, is_cat) {
}
}
cache_delete("feed:" + feed + ":" + is_cat);
} catch (e) {
exception_error("decrement_feed_counter", e);
}

@ -9,8 +9,6 @@ var last_requested_article = false;
var catchup_id_batch = [];
var catchup_timeout_id = false;
var feed_precache_timeout_id = false;
var precache_idle_timeout_id = false;
var cids_requested = [];
var loaded_article_ids = [];
@ -47,8 +45,6 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
if (getInitParam("cdm_auto_catchup") == 1) {
content = content + "<div id='headlines-spacer'></div>";
}
cache_headlines(feed_id, is_cat, reply['headlines']['toolbar'], content);
return;
}
@ -183,9 +179,6 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
}
}
if (headlines_count > 0)
cache_headlines(feed_id, is_cat, reply['headlines']['toolbar'], $("headlines-frame").innerHTML);
if (articles) {
for (var i = 0; i < articles.length; i++) {
var a_id = articles[i]['id'];
@ -195,10 +188,6 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
console.log("no cached articles received");
}
// do not precache stuff after fresh feed
if (feed_id != -3)
precache_headlines();
if (counters)
parse_counters(counters);
else
@ -272,10 +261,6 @@ function showArticleInHeadlines(id) {
//
}
if (article_is_unread && view_mode == "all_articles") {
cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML);
}
markHeadline(id);
if (article_is_unread)
@ -385,8 +370,6 @@ function view(id) {
setActiveArticleId(id);
showArticleInHeadlines(id);
precache_headlines();
if (cached_article && article_is_unread) {
query = query + "&mode=prefetch";
@ -458,8 +441,6 @@ function toggleMark(id, client_only) {
query = query + "&mark=0";
}
cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML);
if (!client_only) {
new Ajax.Request("backend.php", {
parameters: query,
@ -499,8 +480,6 @@ function togglePub(id, client_only, no_effects, note) {
query = query + "&pub=0";
}
cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML);
if (!client_only) {
new Ajax.Request("backend.php", {
parameters: query,
@ -1431,9 +1410,6 @@ function show_labels_in_headlines(transport) {
if (ctr) ctr.innerHTML = elem.labels;
});
cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML);
}
} catch (e) {
exception_error("show_labels_in_headlines", e);
@ -1901,107 +1877,6 @@ function cache_delete(id) {
sessionStorage.removeItem(id);
}
function cache_headlines(feed, is_cat, toolbar_obj, content_obj) {
if (toolbar_obj && content_obj) {
cache_set("feed:" + feed + ":" + is_cat,
JSON.stringify({toolbar: toolbar_obj, content: content_obj}));
} else {
try {
obj = cache_get("feed:" + feed + ":" + is_cat);
if (obj) {
obj = JSON.parse(obj);
if (toolbar_obj) obj.toolbar = toolbar_obj;
if (content_obj) obj.content = content_obj;
cache_set("feed:" + feed + ":" + is_cat, JSON.stringify(obj));
}
} catch (e) {
console.warn("cache_headlines failed: " + e);
}
}
}
function render_local_headlines(feed, is_cat, obj) {
try {
dijit.byId("headlines-toolbar").attr('content',
obj.toolbar);
dijit.byId("headlines-frame").attr('content',
obj.content);
dojo.parser.parse('headlines-toolbar');
$("headlines-frame").scrollTop = 0;
selectArticles('none');
setActiveFeedId(feed, is_cat);
initHeadlinesMenu();
dijit.getEnclosingWidget(
document.forms["main_toolbar_form"].update).attr('disabled',
is_cat || feed <= 0);
precache_headlines();
} catch (e) {
exception_error("render_local_headlines", e);
}
}
function precache_headlines_idle() {
try {
if (getInitParam("bw_limit") != "1" && !feed_precache_timeout_id) {
if (get_timestamp() - _viewfeed_last > 120) {
var feeds = dijit.byId("feedTree").getVisibleUnreadFeeds();
var uncached = [];
feeds.each(function(item) {
if (parseInt(item[0]) > 0 && !cache_get("feed:" + item[0] + ":" + item[1]))
uncached.push(item);
});
if (uncached.length > 0) {
var rf = uncached[Math.floor(Math.random()*uncached.length)];
viewfeed(rf[0], '', rf[1], 0, true);
}
}
}
precache_idle_timeout_id = setTimeout("precache_headlines_idle()", 1000*30);
} catch (e) {
exception_error("precache_headlines_idle", e);
}
}
function precache_headlines() {
try {
if (getInitParam("bw_limit") != "1" && !feed_precache_timeout_id) {
feed_precache_timeout_id = window.setTimeout(function() {
var nuf = getNextUnreadFeed(getActiveFeedId(), activeFeedIsCat());
var nf = dijit.byId("feedTree").getNextFeed(getActiveFeedId(), activeFeedIsCat());
if (nuf && !cache_get("feed:" + nuf + ":" + activeFeedIsCat()))
viewfeed(nuf, '', activeFeedIsCat(), 0, true);
if (nf && nf[0] != nuf && !cache_get("feed:" + nf[0] + ":" + nf[1]))
viewfeed(nf[0], '', nf[1], 0, true);
window.setTimeout(function() {
feed_precache_timeout_id = false;
}, 3000);
}, 1000);
}
} catch (e) {
exception_error("precache_headlines", e);
}
}
function cancelSearch() {
try {
_search_query = "";

Loading…
Cancel
Save