From 23802bc278022fb0bf47422e757f7decd3cd234a Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Thu, 28 Mar 2013 13:21:11 -0400 Subject: [PATCH] Filter out private messages in home view when counting in home unread (imported from commit 6b42168e880269c8fe14f0e2eab98cf03b480f17) --- zephyr/static/js/zephyr.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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;