]> git.wh0rd.org Git - tt-rss.git/commitdiff
view: implement a hack to fake counter updates for current feed and its parent
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 4 Apr 2012 11:34:06 +0000 (15:34 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 4 Apr 2012 11:34:06 +0000 (15:34 +0400)
js/FeedTree.js
js/feedlist.js
js/viewfeed.js

index 38d0846b1c13bdf5f6a4763114e9416b8a6268ff..30e625015d27b47dbe50543c1df8f31659b5e5aa 100644 (file)
@@ -433,5 +433,14 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
                }
 
        },
+       getFeedCategory: function(feed) {
+               try {
+                       return this.getNodesByItem(this.model.store.
+                                       _itemsByIdentity["FEED:" + feed])[0].
+                                       getParent().item.bare_id[0];
 
+               } catch (e) {
+                       return false;
+               }
+       },
 });
index db77d9ca4f4fc9d1efbbbcdc357327d729fb4cd6..98e3c6ca5424b0c13e2cb7e477d20b2372e21853 100644 (file)
@@ -345,6 +345,20 @@ function getFeedUnread(feed, is_cat) {
        return -1;
 }
 
+function getFeedCategory(feed) {
+       try {
+               var tree = dijit.byId("feedTree");
+
+               if (tree && tree.model)
+                       return tree.getFeedCategory(feed);
+
+       } catch (e) {
+               //
+       }
+
+       return false;
+}
+
 function hideOrShowFeeds(hide) {
        var tree = dijit.byId("feedTree");
 
index aac5019b184a4d40d1deecf22e6d2402ac9bd5a1..4e610ca10381050085774adc7c16d5537a2c6338 100644 (file)
@@ -391,6 +391,24 @@ function view(id) {
 
                console.log(query);
 
+               if (article_is_unread) {
+                       var ctr = getFeedUnread(getActiveFeedId(), activeFeedIsCat());
+
+                       if (ctr > 0) {
+                               setFeedUnread(getActiveFeedId(), activeFeedIsCat(), ctr - 1);
+
+                               var cat = parseInt(getFeedCategory(getActiveFeedId()));
+
+                               if (!isNaN(cat)) {
+                                       ctr = getFeedUnread(cat, true);
+
+                                       if (ctr > 0) {
+                                               setFeedUnread(cat, true, ctr - 1);
+                                       }
+                               }
+                       }
+               }
+
                new Ajax.Request("backend.php", {
                        parameters: query,
                        onComplete: function(transport) {