1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-22 02:51:28 +00:00

implement workaround for missing autoloaded headlines for adaptive & unread modes; reduce js debugging (refs #280)

This commit is contained in:
Andrew Dolgov
2011-08-04 15:20:23 +04:00
parent c3fed9e63d
commit 7131797307
3 changed files with 66 additions and 104 deletions

View File

@@ -1,4 +1,4 @@
var _feed_cur_page = 0; //var _feed_cur_page = 0;
var _infscroll_disable = 0; var _infscroll_disable = 0;
var _infscroll_request_sent = 0; var _infscroll_request_sent = 0;
var _search_query = false; var _search_query = false;
@@ -13,13 +13,34 @@ function viewCategory(cat) {
return false; return false;
} }
function viewNextFeedPage() { function loadMoreHeadlines() {
try { try {
//if (!getActiveFeedId()) return; var offset = 0;
console.log("viewNextFeedPage: calling viewfeed(), p: " + parseInt(_feed_cur_page+1)); var view_mode = document.forms["main_toolbar_form"].view_mode.value;
var num_unread = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
var num_all = $$("#headlines-frame > div[id*=RROW]").length;
viewfeed(getActiveFeedId(), '', activeFeedIsCat(), parseInt(_feed_cur_page+1)); // TODO implement marked & published
if (view_mode == "marked") {
console.warn("loadMoreHeadlines: marked is not implemented, falling back.");
offset = num_all;
} else if (view_mode == "published") {
console.warn("loadMoreHeadlines: published is not implemented, falling back.");
offset = num_all;
} else if (view_mode == "unread") {
offset = num_unread;
} else if (view_mode == "adaptive") {
if (num_unread > 0)
offset = num_unread;
else
offset = num_all;
} else {
offset = num_all;
}
viewfeed(getActiveFeedId(), '', activeFeedIsCat(), offset);
} catch (e) { } catch (e) {
exception_error("viewNextFeedPage", e); exception_error("viewNextFeedPage", e);
@@ -31,51 +52,30 @@ function viewfeed(feed, subop, is_cat, offset) {
try { try {
if (is_cat == undefined) is_cat = false; if (is_cat == undefined) is_cat = false;
if (subop == undefined) subop = ''; if (subop == undefined) subop = '';
if (offset == undefined) offset = 0;
// if (!offset) page_offset = 0;
last_requested_article = 0; last_requested_article = 0;
//counters_last_request = 0;
if (feed == getActiveFeedId()) { if (feed == getActiveFeedId()) {
cache_invalidate("F:" + feed); cache_invalidate("F:" + feed);
} }
/* if (getInitParam("theme") == "" || getInitParam("theme") == "compact") {
if (getInitParam("hide_feedlist") == 1) {
Element.hide("feeds-holder");
}
} */
dijit.byId("content-tabs").selectChild( dijit.byId("content-tabs").selectChild(
dijit.byId("content-tabs").getChildren()[0]); dijit.byId("content-tabs").getChildren()[0]);
var force_nocache = false; var force_nocache = false;
var page_offset = 0; if (getActiveFeedId() != feed || offset == 0) {
if (offset > 0) {
page_offset = offset;
} else {
page_offset = 0;
_feed_cur_page = 0;
_infscroll_disable = 0;
}
if (getActiveFeedId() != feed) {
_feed_cur_page = 0;
active_post_id = 0; active_post_id = 0;
_infscroll_disable = 0; _infscroll_disable = 0;
} }
if (page_offset != 0 && !subop) { if (offset != 0 && !subop) {
var date = new Date(); var date = new Date();
var timestamp = Math.round(date.getTime() / 1000); var timestamp = Math.round(date.getTime() / 1000);
console.log(_infscroll_request_sent + " : " + timestamp);
if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) { if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) {
console.log("infscroll request in progress, aborting"); //console.log("infscroll request in progress, aborting");
return; return;
} }
@@ -105,8 +105,6 @@ function viewfeed(feed, subop, is_cat, offset) {
_search_query = false; _search_query = false;
} }
// console.log("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
if (subop == "MarkAllRead") { if (subop == "MarkAllRead") {
var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1"; var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
@@ -127,8 +125,8 @@ function viewfeed(feed, subop, is_cat, offset) {
query = query + "&cat=1"; query = query + "&cat=1";
} }
if (page_offset != 0) { if (offset != 0) {
query = query + "&skip=" + page_offset; query = query + "&skip=" + offset;
// to prevent duplicate feed titles when showing grouped vfeeds // to prevent duplicate feed titles when showing grouped vfeeds
if (vgroup_last_feed) { if (vgroup_last_feed) {
@@ -140,38 +138,6 @@ function viewfeed(feed, subop, is_cat, offset) {
console.log(query); console.log(query);
/* var unread_ctr = -1;
if (!is_cat) unread_ctr = getFeedUnread(feed);
var cache_check = false;
if (unread_ctr != -1 && !page_offset && !force_nocache && !subop) {
var cache_prefix = "";
if (is_cat) {
cache_prefix = "C:";
} else {
cache_prefix = "F:";
}
cache_check = cache_check_param(cache_prefix + feed, unread_ctr);
console.log("headline cache check: " + cache_check);
}
if (cache_check) {
setActiveFeedId(feed, is_cat);
$("headlines-frame").innerHTML = cache_find_param(cache_prefix + feed,
unread_ctr);
request_counters();
remove_splash();
} else { */
if (!is_cat) { if (!is_cat) {
if (!setFeedExpandoIcon(feed, is_cat, 'images/indicator_white.gif')) if (!setFeedExpandoIcon(feed, is_cat, 'images/indicator_white.gif'))
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
@@ -183,9 +149,8 @@ function viewfeed(feed, subop, is_cat, offset) {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif'); setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
headlines_callback2(transport, page_offset); headlines_callback2(transport, offset);
} }); } });
// }
} catch (e) { } catch (e) {
exception_error("viewfeed", e); exception_error("viewfeed", e);

View File

@@ -4944,10 +4944,7 @@
$topmost_article_ids = array(); $topmost_article_ids = array();
if (!$offset) { if (!$offset) $offset = 0;
$offset = 0;
}
if ($subop == "undefined") $subop = ""; if ($subop == "undefined") $subop = "";
$subop_split = explode(":", $subop); $subop_split = explode(":", $subop);
@@ -5024,12 +5021,12 @@
$match_on = "both"; $match_on = "both";
} }
$real_offset = $offset * $limit; //$real_offset = $offset * $limit;
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info); if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
$qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view,
$search, $search_mode, $match_on, $override_order, $real_offset); $search, $search_mode, $match_on, $override_order, $offset);
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info); if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
@@ -5055,7 +5052,7 @@
if (db_num_rows($result) > 0) { if (db_num_rows($result) > 0) {
$lnum = $limit*$offset; $lnum = $offset+1;
$num_unread = 0; $num_unread = 0;
$cur_feed_title = ''; $cur_feed_title = '';
@@ -5532,13 +5529,6 @@
} }
} }
# if (!$offset) {
# if ($headlines_count > 0) print "</div>";
# print "</div>";
# }
#print "]]></content>";
return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
$vgroup_last_feed, $reply['content'], $reply['toolbar']); $vgroup_last_feed, $reply['content'], $reply['toolbar']);
} }

View File

@@ -17,13 +17,13 @@ var cache_added = [];
var catchup_id_batch = []; var catchup_id_batch = [];
var catchup_timeout_id = false; var catchup_timeout_id = false;
function headlines_callback2(transport, feed_cur_page) { function headlines_callback2(transport, offset) {
try { try {
handle_rpc_json(transport); handle_rpc_json(transport);
loading_set_progress(25); loading_set_progress(25);
console.log("headlines_callback2 [page=" + feed_cur_page + "]"); console.log("headlines_callback2 [offset=" + offset + "]");
var is_cat = false; var is_cat = false;
var feed_id = false; var feed_id = false;
@@ -48,7 +48,7 @@ function headlines_callback2(transport, feed_cur_page) {
update_btn.disabled = !(feed_id >= 0 && !is_cat); update_btn.disabled = !(feed_id >= 0 && !is_cat);
try { try {
if (feed_cur_page == 0) { if (offset == 0) {
$("headlines-frame").scrollTop = 0; $("headlines-frame").scrollTop = 0;
} }
} catch (e) { }; } catch (e) { };
@@ -68,7 +68,7 @@ function headlines_callback2(transport, feed_cur_page) {
var articles = reply['articles']; var articles = reply['articles'];
var runtime_info = reply['runtime-info']; var runtime_info = reply['runtime-info'];
if (feed_cur_page == 0) { if (offset == 0) {
dijit.byId("headlines-frame").attr('content', dijit.byId("headlines-frame").attr('content',
reply['headlines']['content']); reply['headlines']['content']);
@@ -78,9 +78,9 @@ function headlines_callback2(transport, feed_cur_page) {
var hsp = $("headlines-spacer"); var hsp = $("headlines-spacer");
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"}); if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
if (!_infscroll_disable) /* if (!_infscroll_disable)
hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " + hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
__("Loading, please wait..."); __("Loading, please wait..."); */
dijit.byId('headlines-frame').domNode.appendChild(hsp); dijit.byId('headlines-frame').domNode.appendChild(hsp);
@@ -107,9 +107,11 @@ function headlines_callback2(transport, feed_cur_page) {
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"}); if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
if (!_infscroll_disable) /* if (!_infscroll_disable)
hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " + hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
__("Loading, please wait..."); __("Loading, please wait..."); */
fixHeadlinesOrder(getLoadedArticleIds());
c.domNode.appendChild(hsp); c.domNode.appendChild(hsp);
@@ -156,7 +158,7 @@ function headlines_callback2(transport, feed_cur_page) {
__('Could not update headlines (invalid object received)') + "</div>"); __('Could not update headlines (invalid object received)') + "</div>");
} }
_feed_cur_page = feed_cur_page; //_feed_cur_page = feed_cur_page;
_infscroll_request_sent = 0; _infscroll_request_sent = 0;
notify(""); notify("");
@@ -1274,7 +1276,7 @@ function preloadBatchedArticles() {
var id = articles[i]['id']; var id = articles[i]['id'];
if (!cache_check(id)) { if (!cache_check(id)) {
cache_inject(id, articles[i]['content']); cache_inject(id, articles[i]['content']);
console.log("preloaded article: " + id); //console.log("preloaded article: " + id);
} }
} }
} }); } });
@@ -1290,7 +1292,7 @@ function preloadArticleUnderPointer(id) {
if (post_under_pointer == id && !cache_check(id)) { if (post_under_pointer == id && !cache_check(id)) {
console.log("trying to preload article " + id); //console.log("trying to preload article " + id);
var neighbor_ids = getRelativePostIds(id, 1); var neighbor_ids = getRelativePostIds(id, 1);
@@ -1348,7 +1350,12 @@ function headlines_scroll_handler(e) {
if (hsp && (e.scrollTop + e.offsetHeight > hsp.offsetTop) || if (hsp && (e.scrollTop + e.offsetHeight > hsp.offsetTop) ||
e.scrollTop + e.offsetHeight > e.scrollHeight - 100) { e.scrollTop + e.offsetHeight > e.scrollHeight - 100) {
viewNextFeedPage(); hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
__("Loading, please wait...");
loadMoreHeadlines();
//viewNextFeedPage();
} }
} else { } else {
if (hsp) hsp.innerHTML = ""; if (hsp) hsp.innerHTML = "";