From: Andrew Dolgov Date: Thu, 5 Apr 2012 07:58:50 +0000 (+0400) Subject: add counter hack to combined mode X-Git-Tag: 1.5.11~13 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=de44b9a61e4b507e1d60331e0ab11bb5f84a86e8;p=tt-rss.git add counter hack to combined mode --- diff --git a/js/feedlist.js b/js/feedlist.js index 98e3c6ca..02057c06 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -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); + } +} diff --git a/js/viewfeed.js b/js/viewfeed.js index 4e610ca1..e8d449a2 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -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); }