prefetch old articles when necessary

This commit is contained in:
Andrew Dolgov 2007-05-15 07:19:48 +01:00
parent 7289eacf91
commit addb583694
3 changed files with 21 additions and 9 deletions

View file

@ -155,9 +155,9 @@
// in prefetch mode we only output requested cids, main article // in prefetch mode we only output requested cids, main article
// just gets marked as read (it already exists in client cache) // just gets marked as read (it already exists in client cache)
if ($mode != "prefetch") { if ($mode == "") {
outputArticleXML($link, $id, $feed_id); outputArticleXML($link, $id, $feed_id);
} else { } else if ($mode == "prefetch") {
catchupArticleById($link, $id, 0); catchupArticleById($link, $id, 0);
} }
@ -167,9 +167,11 @@
} }
} }
if ($mode != "prefetch_old") {
print "<counters>"; print "<counters>";
getAllCounters($link, $omode); getAllCounters($link, $omode);
print "</counters>"; print "</counters>";
}
print "</reply>"; print "</reply>";
} }

View file

@ -50,7 +50,7 @@ function dlg_frefresh_callback() {
if (getActiveFeedId() == _qfd_deleted_feed) { if (getActiveFeedId() == _qfd_deleted_feed) {
var h = document.getElementById("headlines-frame"); var h = document.getElementById("headlines-frame");
if (h) { if (h) {
h.innerHTML = "<div class='whiteBox'>No feed selected.</div>"; h.innerHTML = "<div class='whiteBox'>" + __('No feed selected.') + "</div>";
} }
} }

View file

@ -50,11 +50,12 @@ function headlines_callback() {
if (counters) { if (counters) {
debug("parsing piggybacked counters: " + counters); debug("parsing piggybacked counters: " + counters);
parse_counters(counters, false); parse_counters(counters, false);
} else {
debug("counters container not found in reply");
} }
} else { } else {
debug("headlines_callback: returned no XML object"); debug("headlines_callback: returned no XML object");
f.innerHTML = xmlhttp.responseText; f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
update_all_counters();
} }
if (typeof correctPNG != 'undefined') { if (typeof correctPNG != 'undefined') {
@ -122,6 +123,7 @@ function article_callback() {
} else { } else {
debug("article_callback: returned no XML object"); debug("article_callback: returned no XML object");
f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
} }
} catch (e) { } catch (e) {
exception_error("article_callback", e); exception_error("article_callback", e);
@ -144,7 +146,7 @@ function article_callback() {
debug("parsing piggybacked counters: " + counters); debug("parsing piggybacked counters: " + counters);
parse_counters(counters, false); parse_counters(counters, false);
} else { } else {
update_all_counters(); debug("counters container not found in reply");
} }
} }
@ -253,6 +255,14 @@ function view(id, feed_id, skip_history) {
} else if (cached_article) { } else if (cached_article) {
query = query + "&mode=prefetch_old";
debug(query);
xmlhttp.open("GET", query, true);
xmlhttp.onreadystatechange=article_callback;
xmlhttp.send(null);
render_article(cached_article); render_article(cached_article);
} }