Don't add messages to zhome if the message's Stream has in_home_view=false.

We also introduce support narrowing to "home" and "all".

(imported from commit 53b8dea9c6045a0cde368b3163f6fd6ecde1c649)
This commit is contained in:
Luke Faraone 2013-01-30 15:10:55 -05:00
parent 3de93f2b2b
commit 77d0a07e4f
3 changed files with 19 additions and 3 deletions

View File

@ -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))

View File

@ -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;
}

View File

@ -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;
}