view: implement a hack to fake counter updates for current feed and its parent

This commit is contained in:
Andrew Dolgov 2012-04-04 15:34:06 +04:00
parent 21e42e5fb0
commit 6c8e8fbdc9
3 changed files with 41 additions and 0 deletions

View 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;
}
},
});

View 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");

View 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) {