Counting dupe feeds only once in unread counts.

This commit is contained in:
Samuel Clay 2014-01-14 12:06:34 -08:00
parent 4f7ddacb87
commit 22de79a0d7

View file

@ -252,15 +252,17 @@ NEWSBLUR.Collections.Folders = Backbone.Collection.extend({
});
},
unread_counts: function(sum_total) {
unread_counts: function(sum_total, seen_feeds) {
if (!seen_feeds) seen_feeds = [];
var counts = this.reduce(function(counts, item) {
if (item.is_feed()) {
if (item.is_feed() && !_.contains(seen_feeds, item.feed.id)) {
var feed_counts = item.feed.unread_counts();
counts['ps'] += feed_counts['ps'];
counts['nt'] += feed_counts['nt'];
counts['ng'] += feed_counts['ng'];
seen_feeds.push(item.feed.id);
} else if (item.is_folder()) {
var folder_counts = item.folders.unread_counts();
var folder_counts = item.folders.unread_counts(false, seen_feeds);
counts['ps'] += folder_counts['ps'];
counts['nt'] += folder_counts['nt'];
counts['ng'] += folder_counts['ng'];