mirror of https://github.com/zulip/zulip.git
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:
parent
3de93f2b2b
commit
77d0a07e4f
|
@ -79,6 +79,9 @@ exports.describe = function (operators) {
|
||||||
|
|
||||||
case 'search':
|
case 'search':
|
||||||
return 'messages containing ' + operand;
|
return 'messages containing ' + operand;
|
||||||
|
|
||||||
|
case 'in':
|
||||||
|
return 'messages in ' + operand;
|
||||||
}
|
}
|
||||||
return '(unknown operator)';
|
return '(unknown operator)';
|
||||||
}).join(', ');
|
}).join(', ');
|
||||||
|
@ -109,6 +112,10 @@ exports.parse = function (str) {
|
||||||
return operators;
|
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.
|
// Build a filter function from a list of operators.
|
||||||
function build_filter(operators_mixed_case) {
|
function build_filter(operators_mixed_case) {
|
||||||
var operators = [];
|
var operators = [];
|
||||||
|
@ -133,6 +140,15 @@ function build_filter(operators_mixed_case) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'in':
|
||||||
|
if (operand === 'home') {
|
||||||
|
return exports.in_home(message);
|
||||||
|
}
|
||||||
|
else if (operand === 'all') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'stream':
|
case 'stream':
|
||||||
if ((message.type !== 'stream') ||
|
if ((message.type !== 'stream') ||
|
||||||
(message.display_recipient.toLowerCase() !== operand))
|
(message.display_recipient.toLowerCase() !== operand))
|
||||||
|
|
|
@ -94,7 +94,7 @@ var colorpicker_options = {
|
||||||
function create_sub(stream_name, attrs) {
|
function create_sub(stream_name, attrs) {
|
||||||
var sub = $.extend({}, {name: stream_name, color: default_color, id: next_sub_id++,
|
var sub = $.extend({}, {name: stream_name, color: default_color, id: next_sub_id++,
|
||||||
render_subscribers: should_render_subscribers(),
|
render_subscribers: should_render_subscribers(),
|
||||||
subscribed: true}, attrs);
|
subscribed: true, in_home_view: true}, attrs);
|
||||||
stream_info[stream_name.toLowerCase()] = sub;
|
stream_info[stream_name.toLowerCase()] = sub;
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,8 +490,8 @@ function add_messages(messages, add_to_home) {
|
||||||
return (elem.id >= selected_message_id && ! message_in_table.zhome[elem.id]);
|
return (elem.id >= selected_message_id && ! message_in_table.zhome[elem.id]);
|
||||||
});
|
});
|
||||||
message_array = top_messages_home.concat(message_array).concat(bottom_messages_home);
|
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(top_messages_home, 'zhome', narrow.in_home, "top", true);
|
||||||
add_to_table(bottom_messages_home, 'zhome', function () { return true; }, "bottom", true);
|
add_to_table(bottom_messages_home, 'zhome', narrow.in_home, "bottom", true);
|
||||||
if ((top_messages_home.length > 0) && !narrow.active()) {
|
if ((top_messages_home.length > 0) && !narrow.active()) {
|
||||||
prepended = true;
|
prepended = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue