]> git.wh0rd.org Git - tt-rss.git/commitdiff
better feedlist reloading on subscribed feeds count change
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 23 Nov 2010 10:03:36 +0000 (13:03 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 23 Nov 2010 10:03:36 +0000 (13:03 +0300)
feedlist.js
functions.js
functions.php
tt-rss.js

index a39748f1c4d325761575712fda20f70fc50b1002..9270ea4bfdd9bc721996de76d90a141ac840ed0e 100644 (file)
@@ -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);
        }
index 11f1f4e0a92c9286baa822457c23ea0728dc3849..02e93eef8d827431c3682adab3337136e83e5bd1 100644 (file)
@@ -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);
                                                        }
                                                } });
                
index ce2c2e7e908a1bc90b4ac7a1e426d12a17aac4c7..b4105e805f6a07a93adf35fcde5bb1624120c79a 100644 (file)
                $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;
        }
 
        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');
 
index d88554669dec2d58cc50402d9e2b755dce74f32e..f3aad8c1d912e10a798894b554b914c47334fd58 100644 (file)
--- 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('');
        }