From 8cd576a12ad94175fc511bab83191d92f83aa0b0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Nov 2010 13:03:36 +0300 Subject: [PATCH] better feedlist reloading on subscribed feeds count change --- feedlist.js | 11 ----------- functions.js | 12 +++--------- functions.php | 18 ++++++++++++------ tt-rss.js | 17 +++++++---------- 4 files changed, 22 insertions(+), 36 deletions(-) diff --git a/feedlist.js b/feedlist.js index a39748f1..9270ea4b 100644 --- a/feedlist.js +++ b/feedlist.js @@ -343,17 +343,6 @@ function parse_counters(reply, scheduled_call) { hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); - var feeds_stored = number_of_feeds; - - if (feeds_stored != feeds_found) { - number_of_feeds = feeds_found; - - if (feeds_stored != 0 && feeds_found != 0) { - console.log("Subscribed feed number changed, refreshing feedlist"); - setTimeout('updateFeedList()', 50); - } - } - } catch (e) { exception_error("parse_counters", e); } diff --git a/functions.js b/functions.js index 11f1f4e0..02e93eef 100644 --- a/functions.js +++ b/functions.js @@ -1129,7 +1129,8 @@ function unsubscribeFeed(feed_id, title) { if (inPreferences()) { updateFeedList(); } else { - dlg_frefresh_callback(transport, feed_id); + if (feed_id == getActiveFeedId()) + setTimeout("viewfeed(-5)", 100); } } }); @@ -1469,12 +1470,7 @@ function editFeed(feed, event) { parameters: dojo.objectToQuery(dialog.attr('value')), onComplete: function(transport) { dialog.hide(); - if (inPreferences()) { - updateFeedList(); - } else { - notify(''); - dlg_frefresh_callback(transport); - } + updateFeedList(); }}) } }, @@ -1540,8 +1536,6 @@ function feedBrowser() { if (inPreferences()) { updateFeedList(); - } else { - setTimeout('updateFeedList(false, false)', 50); } } }); diff --git a/functions.php b/functions.php index ce2c2e7e..b4105e80 100644 --- a/functions.php +++ b/functions.php @@ -3143,12 +3143,15 @@ $params["bw_limit"] = (int) $_SESSION["bw_limit"]; $params["offline_enabled"] = (int) get_pref($link, "ENABLE_OFFLINE_READING"); - $result = db_query($link, "SELECT COUNT(*) AS cf FROM + $result = db_query($link, "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]); - $num_feeds = db_fetch_result($result, 0, "cf"); + $max_feed_id = db_fetch_result($result, 0, "mid"); + $num_feeds = db_fetch_result($result, 0, "nf"); + $params["max_feed_id"] = (int) $max_feed_id; $params["num_feeds"] = (int) $num_feeds; + $params["collapsed_feedlist"] = (int) get_pref($link, "_COLLAPSED_FEEDLIST"); return $params; @@ -3161,14 +3164,17 @@ } function make_runtime_info($link) { - $result = db_query($link, "SELECT COUNT(*) AS cf FROM + $data = array(); + + $result = db_query($link, "SELECT MAX(id) AS mid, COUNT(*) AS nf FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]); - $num_feeds = db_fetch_result($result, 0, "cf"); + $max_feed_id = db_fetch_result($result, 0, "mid"); + $num_feeds = db_fetch_result($result, 0, "nf"); - $data = array(); + $data["max_feed_id"] = (int) $max_feed_id; + $data["num_feeds"] = (int) $num_feeds; - $data['num_feeds'] = (int) $num_feeds; $data['last_article_id'] = getLastArticleId($link); $data['cdm_expanded'] = get_pref($link, 'CDM_EXPANDED'); diff --git a/tt-rss.js b/tt-rss.js index d8855466..f3aad8c1 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -3,7 +3,6 @@ var global_unread = -1; var firsttime_update = true; var _active_feed_id = 0; var _active_feed_is_cat = false; -var number_of_feeds = 0; var hotkey_prefix = false; var hotkey_prefix_pressed = false; var init_params = {}; @@ -50,15 +49,6 @@ function setActiveFeedId(id, is_cat) { } -function dlg_frefresh_callback(transport, deleted_feed) { - if (getActiveFeedId() == deleted_feed) { - setTimeout("viewfeed(-5)", 100); - } - - setTimeout('updateFeedList()', 50); - closeInfoBox(); -} - function updateFeedList() { try { @@ -522,6 +512,13 @@ function parse_runtime_info(elem) { return; } + if (k == "max_feed_id" || k == "num_feeds") { + if (init_params[k] != v) { + console.log("feed count changed, need to reload feedlist."); + updateFeedList(); + } + } + init_params[k] = v; notify(''); } -- 2.39.5