]> git.wh0rd.org Git - tt-rss.git/commitdiff
properly update local vfeed counters
authorAndrew Dolgov <fox@bah.org.ru>
Wed, 4 Feb 2009 06:51:31 +0000 (09:51 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Wed, 4 Feb 2009 06:51:31 +0000 (09:51 +0300)
feedlist.js
functions.js
viewfeed.js

index 4609a233865c438b907746ea89d43bc1d3ad7559..6ee3de1cc4f389f093cfc980bc12ba6b0aa5db18 100644 (file)
@@ -1013,8 +1013,54 @@ function request_counters() {
        }
 }
 
-function update_feedlist_counters() {
+function set_feedlist_counter(id, ctr) {
        try {
+
+               var feedctr = document.getElementById("FEEDCTR-" + id);
+               var feedu = document.getElementById("FEEDU-" + id);
+               var feedr = document.getElementById("FEEDR-" + id);
+
+               if (feedctr && feedu && feedr) {
+
+                       var row_needs_hl = (ctr > 0 && ctr > parseInt(feedu.innerHTML));
+
+                       feedu.innerHTML = ctr;
+
+                       if (ctr > 0) {                                  
+                               feedctr.className = "feedCtrHasUnread";
+                               if (!feedr.className.match("Unread")) {
+                                       var is_selected = feedr.className.match("Selected");
+       
+                                       feedr.className = feedr.className.replace("Selected", "");
+                                       feedr.className = feedr.className.replace("Unread", "");
+       
+                                       feedr.className = feedr.className + "Unread";
+       
+                                       if (is_selected) {
+                                               feedr.className = feedr.className + "Selected";
+                                       }       
+                                       
+                               }
+
+                               if (row_needs_hl) { 
+                                       new Effect.Highlight(feedr, {duration: 1, startcolor: "#fff7d5",
+                                               queue: { position:'end', scope: 'EFQ-' + id, limit: 1 } } );
+                               }
+                       } else {
+                               feedctr.className = "feedCtrNoUnread";
+                               feedr.className = feedr.className.replace("Unread", "");
+                       }                       
+               }
+
+       } catch (e) {
+               exception_error("set_feedlist_counter", e);
+       }
+}
+
+function update_local_feedlist_counters() {
+       try {
+               if (!db) return;
+
                var rs = db.execute("SELECT feeds.id,COUNT(articles.id) "+
                        "FROM feeds LEFT JOIN articles ON (feed_id = feeds.id) "+
                        "WHERE unread = 1 OR unread IS NULL GROUP BY feeds.id "+
@@ -1024,50 +1070,20 @@ function update_feedlist_counters() {
                        var id = rs.field(0);
                        var ctr = rs.field(1);
 
-                       var feedctr = document.getElementById("FEEDCTR-" + id);
-                       var feedu = document.getElementById("FEEDU-" + id);
-                       var feedr = document.getElementById("FEEDR-" + id);
-
-                       if (feedctr && feedu && feedr) {
+                       set_feedlist_counter(id, ctr);
 
-                               var row_needs_hl = (ctr > 0 && ctr > parseInt(feedu.innerHTML));
-
-                               feedu.innerHTML = ctr;
-       
-                               if (ctr > 0) {                                  
-                                       feedctr.className = "feedCtrHasUnread";
-                                       if (!feedr.className.match("Unread")) {
-                                               var is_selected = feedr.className.match("Selected");
-               
-                                               feedr.className = feedr.className.replace("Selected", "");
-                                               feedr.className = feedr.className.replace("Unread", "");
-               
-                                               feedr.className = feedr.className + "Unread";
-               
-                                               if (is_selected) {
-                                                       feedr.className = feedr.className + "Selected";
-                                               }       
-                                               
-                                       }
-
-                                       if (row_needs_hl) { 
-                                               new Effect.Highlight(feedr, {duration: 1, startcolor: "#fff7d5",
-                                                       queue: { position:'end', scope: 'EFQ-' + id, limit: 1 } } );
-                                       }
-                               } else {
-                                       feedctr.className = "feedCtrNoUnread";
-                                       feedr.className = feedr.className.replace("Unread", "");
-                               }                       
-                       }
                        rs.next();
                }
 
+               set_feedlist_counter(-4, get_local_feed_unread(-4));
+               set_feedlist_counter(-1, get_local_feed_unread(-1));
+
                hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
 
                global_unread = get_local_feed_unread(-4);
                updateTitle();
 
        } catch (e) {
-               exception_error("update_feedlist_counters", e);
+               exception_error("update_local_feedlist_counters", e);
        }
 }
index 99ae1d43041e584c923e91e571873d49cc7fa996..837a6b42f35e7ae8d248f5cb9e547226f8de0562 100644 (file)
@@ -627,6 +627,8 @@ function parse_counters_reply(transport, scheduled_call) {
 function all_counters_callback2(transport, async_call) {
        try {
                if (async_call) async_counters_work = true;
+               
+               if (offline_mode) return;
 
                debug("<b>all_counters_callback2 IN: " + transport + "</b>");
                parse_counters_reply(transport);
index 3c9b306417a401f65ab4062d7a304284fb896784..5285e4d16687288ea11280504d797f9625a4c82c 100644 (file)
@@ -396,7 +396,7 @@ function view_offline(id, feed_id) {
                }
 
                render_article("FIXME");
-               update_feedlist_counters();
+               update_local_feedlist_counters();
 
                return false;
 
@@ -585,6 +585,8 @@ function toggleMark(id, client_only, no_effects) {
 
                }
 
+               update_local_feedlist_counters();
+
                if (!client_only) {
                        debug(query);