From 534edfaf33487be09e813aa323aa618f9ffd5273 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Fri, 27 Sep 2013 16:55:24 -0400 Subject: [PATCH] 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) --- static/js/unread.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/static/js/unread.js b/static/js/unread.js index 1a8a64f711..e56d4c6435 100644 --- a/static/js/unread.js +++ b/static/js/unread.js @@ -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; + } } });