From 6c8e8fbdc9a9a9ee0412a0f36698fd03a2954839 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 4 Apr 2012 15:34:06 +0400 Subject: [PATCH] view: implement a hack to fake counter updates for current feed and its parent --- js/FeedTree.js | 9 +++++++++ js/feedlist.js | 14 ++++++++++++++ js/viewfeed.js | 18 ++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/js/FeedTree.js b/js/FeedTree.js index 38d0846b1..30e625015 100644 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -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; + } + }, }); diff --git a/js/feedlist.js b/js/feedlist.js index db77d9ca4..98e3c6ca5 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -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"); diff --git a/js/viewfeed.js b/js/viewfeed.js index aac5019b1..4e610ca10 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -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) {