From 8292123ebc805da990f7f1a1b0ebb2b3e1508cec Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 11 Aug 2015 10:06:30 +0300 Subject: [PATCH] assorted fixes for keyboard navigation which hopefully don't break everything else --- js/feedlist.js | 5 +---- js/viewfeed.js | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/js/feedlist.js b/js/feedlist.js index 6284534d..05c50228 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -1,6 +1,5 @@ var _infscroll_disable = 0; var _infscroll_request_sent = 0; -var _infscroll_tmp_disable = 0; var _search_query = false; var _viewfeed_last = 0; @@ -15,9 +14,7 @@ function viewCategory(cat) { function loadMoreHeadlines() { try { - console.log("loadMoreHeadlines: " + _infscroll_tmp_disable); - - if (_infscroll_tmp_disable) return; + console.log("loadMoreHeadlines"); var offset = 0; diff --git a/js/viewfeed.js b/js/viewfeed.js index d73d388a..243e9983 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -15,6 +15,8 @@ var loaded_article_ids = []; var _last_headlines_update = 0; var current_first_id = 0; +var _catchup_request_sent = false; + var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null; function headlines_callback2(transport, offset, background, infscroll_req) { @@ -1319,9 +1321,15 @@ function headlines_scroll_handler(e) { window.clearTimeout(catchup_timeout_id); if (!_infscroll_request_sent) { - catchup_timeout_id = window.setTimeout('catchupBatchedArticles()', - 500); + if (catchup_id_batch.length < 10) { + catchup_timeout_id = window.setTimeout('catchupBatchedArticles()', + 500); + } else { + catchupBatchedArticles(); + } } + + catchupBatchedArticles(); } if (_infscroll_disable) { @@ -1356,7 +1364,7 @@ function openNextUnreadFeed() { function catchupBatchedArticles() { try { - if (catchup_id_batch.length > 0 && !_infscroll_request_sent) { + if (catchup_id_batch.length > 0 && !_infscroll_request_sent && !_catchup_request_sent) { // make a copy of the array var batch = catchup_id_batch.slice(); @@ -1365,16 +1373,18 @@ function catchupBatchedArticles() { console.log(query); + _catchup_request_sent = true; + new Ajax.Request("backend.php", { parameters: query, onComplete: function(transport) { handle_rpc_json(transport); + _catchup_request_sent = false; + reply = JSON.parse(transport.responseText); var batch = reply.ids; - _infscroll_tmp_disable = 1; - batch.each(function(id) { console.log(id); var elem = $("RROW-" + id); @@ -1382,8 +1392,6 @@ function catchupBatchedArticles() { catchup_id_batch.remove(id); }); - _infscroll_tmp_disable = 0; - updateFloatingTitle(true); } }); @@ -1509,6 +1517,8 @@ function cdmCollapseArticle(event, id, unmark) { function cdmExpandArticle(id, noexpand) { try { + if (getInitParam("cdm_expanded")) return; + console.log("cdmExpandArticle " + id); if (!$("RROW-" + id)) return false; @@ -1563,6 +1573,7 @@ function cdmExpandArticle(id, noexpand) { if (!noexpand) toggleUnread(id, 0, true); + toggleSelected(id); $("RROW-" + id).addClassName("active"); @@ -1702,8 +1713,11 @@ function dismissReadArticles() { } } +// we don't really hide rows anymore function getVisibleArticleIds() { - var ids = []; + return getLoadedArticleIds(); + + /*var ids = []; try { @@ -1717,7 +1731,7 @@ function getVisibleArticleIds() { exception_error("getVisibleArticleIds", e); } - return ids; + return ids; */ } function cdmClicked(event, id) {