add counter hack to combined mode

This commit is contained in:
Andrew Dolgov 2012-04-05 11:58:50 +04:00
parent 6c8e8fbdc9
commit de44b9a61e
2 changed files with 39 additions and 15 deletions

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

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