Compute stream/home unread counts from unread.unread_subjects.

These two data structures are kind of redundant:

  unread_counts['stream']
  unread_subjects

We are deprecating the former.  The latter is more flexible for
features like muting.

Now, in get_counts(), we compute home counts and stream counts
in the same loop that computes subject counts.

(imported from commit c8d0ea12a56d0128811e0aa165de9882546906a5)
This commit is contained in:
Steve Howell 2013-09-27 16:55:24 -04:00
parent bbdf18b106
commit 534edfaf33

View File

@ -121,18 +121,18 @@ exports.get_counts = function () {
return true;
}
var count = msgs.num_items();
res.stream_count.set(stream, count);
if (stream_data.in_home_view(stream)) {
res.home_unread_messages += count;
}
if (unread_subjects.has(stream)) {
res.subject_count.set(stream, new Dict());
var stream_count = 0;
unread_subjects.get(stream).each(function (msgs, subject) {
res.subject_count.get(stream).set(subject, msgs.num_items());
var subject_count = msgs.num_items();
res.subject_count.get(stream).set(subject, subject_count);
stream_count += subject_count;
});
res.stream_count.set(stream, stream_count);
if (stream_data.in_home_view(stream)) {
res.home_unread_messages += stream_count;
}
}
});