diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 1f00a96b35..1d7ce6e3cc 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -241,20 +241,23 @@ function update_unread_counts() { return valid.length; } + function only_in_home_view(msgids) { + return $.grep(msgids, function (msgid) { + return home_msg_list.get(msgid) !== undefined; + }); + } + $.each(unread_counts.stream, function(index, obj) { var count = Object.keys(obj).length; ui.set_count("stream", index, count); if (narrow.stream_in_home(index)) { - var in_home_view = $.grep(Object.keys(obj), function (msgid) { - return home_msg_list.get(msgid) !== undefined; - }); - home_unread_messages += newer_than_pointer_count(in_home_view); + home_unread_messages += newer_than_pointer_count(only_in_home_view(Object.keys(obj))); } }); var pm_count = 0; $.each(unread_counts["private"], function(index, obj) { - pm_count += newer_than_pointer_count(Object.keys(obj)); + pm_count += newer_than_pointer_count(only_in_home_view(Object.keys(obj))); }); ui.set_count("global", "private", pm_count); home_unread_messages += pm_count;