]> git.wh0rd.org Git - tt-rss.git/commitdiff
add counter hack to combined mode
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 5 Apr 2012 07:58:50 +0000 (11:58 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 5 Apr 2012 07:58:50 +0000 (11:58 +0400)
js/feedlist.js
js/viewfeed.js

index 98e3c6ca5424b0c13e2cb7e477d20b2372e21853..02057c06a6dd98e0ad88228a4c7dcdb6c1910e27 100644 (file)
@@ -524,3 +524,28 @@ function catchupFeed(feed, is_cat) {
                exception_error("catchupFeed", e);
        }
 }
+
+function decrementFeedCounter(feed, is_cat) {
+       try {
+               var ctr = getFeedUnread(feed, is_cat);
+
+               if (ctr > 0) {
+                       setFeedUnread(feed, is_cat, ctr - 1);
+
+                       if (!is_cat) {
+                               var cat = parseInt(getFeedCategory(feed));
+
+                               if (!isNaN(cat)) {
+                                       ctr = getFeedUnread(cat, true);
+
+                                       if (ctr > 0) {
+                                               setFeedUnread(cat, true, ctr - 1);
+                                       }
+                               }
+                       }
+               }
+
+       } catch (e) {
+               exception_error("decrement_feed_counter", e);
+       }
+}
index 4e610ca10381050085774adc7c16d5537a2c6338..e8d449a239f145bbcc4d2d7947385188c3e9d2f0 100644 (file)
@@ -392,21 +392,7 @@ 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);
-                                       }
-                               }
-                       }
+                       decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
                }
 
                new Ajax.Request("backend.php", {
@@ -1628,6 +1614,7 @@ function cdmClicked(event, id) {
                                toggleSelected(id);
 
                                var elem = $("RROW-" + id);
+                               var article_is_unread = elem.hasClassName("Unread");
 
                                if (elem)
                                        elem.removeClassName("Unread");
@@ -1642,6 +1629,10 @@ function cdmClicked(event, id) {
 
                                active_post_id = id;
 
+                               if (article_is_unread) {
+                                       decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
+                               }
+
                                var query = "?op=rpc&method=catchupSelected" +
                                        "&cmode=0&ids=" + param_escape(id);
 
@@ -1656,6 +1647,14 @@ function cdmClicked(event, id) {
 
                } else {
                        toggleSelected(id, true);
+
+                       var elem = $("RROW-" + id);
+                       var article_is_unread = elem.hasClassName("Unread");
+
+                       if (article_is_unread) {
+                               decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
+                       }
+
                        toggleUnread(id, 0, false);
                        zoomToArticle(event, id);
                }