diff --git a/zephyr/static/js/narrow.js b/zephyr/static/js/narrow.js index 4961973a65..57ab294656 100644 --- a/zephyr/static/js/narrow.js +++ b/zephyr/static/js/narrow.js @@ -79,6 +79,9 @@ exports.describe = function (operators) { case 'search': return 'messages containing ' + operand; + + case 'in': + return 'messages in ' + operand; } return '(unknown operator)'; }).join(', '); @@ -109,6 +112,10 @@ exports.parse = function (str) { return operators; }; +exports.in_home = function (message) { + return message.type === "private" || subs.have(message.display_recipient).in_home_view; +}; + // Build a filter function from a list of operators. function build_filter(operators_mixed_case) { var operators = []; @@ -133,6 +140,15 @@ function build_filter(operators_mixed_case) { } break; + case 'in': + if (operand === 'home') { + return exports.in_home(message); + } + else if (operand === 'all') { + return true; + } + break; + case 'stream': if ((message.type !== 'stream') || (message.display_recipient.toLowerCase() !== operand)) diff --git a/zephyr/static/js/subs.js b/zephyr/static/js/subs.js index 36e931ec35..7c131039f2 100644 --- a/zephyr/static/js/subs.js +++ b/zephyr/static/js/subs.js @@ -94,7 +94,7 @@ var colorpicker_options = { function create_sub(stream_name, attrs) { var sub = $.extend({}, {name: stream_name, color: default_color, id: next_sub_id++, render_subscribers: should_render_subscribers(), - subscribed: true}, attrs); + subscribed: true, in_home_view: true}, attrs); stream_info[stream_name.toLowerCase()] = sub; return sub; } diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 2a6a9aa429..3fc1c17b1b 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -490,8 +490,8 @@ function add_messages(messages, add_to_home) { return (elem.id >= selected_message_id && ! message_in_table.zhome[elem.id]); }); message_array = top_messages_home.concat(message_array).concat(bottom_messages_home); - add_to_table(top_messages_home, 'zhome', function () { return true; }, "top", true); - add_to_table(bottom_messages_home, 'zhome', function () { return true; }, "bottom", true); + add_to_table(top_messages_home, 'zhome', narrow.in_home, "top", true); + add_to_table(bottom_messages_home, 'zhome', narrow.in_home, "bottom", true); if ((top_messages_home.length > 0) && !narrow.active()) { prepended = true; }