mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 04:12:02 +00:00
Improve stream in search_suggestions.js.
This commit is contained in:
@@ -44,24 +44,22 @@ function match_criteria(operators, criteria) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_stream_suggestions(operators) {
|
function get_stream_suggestions(last, operators) {
|
||||||
var query;
|
if (!(last.operator === 'stream' || last.operator === 'search'
|
||||||
|
|| last.operator === '')) {
|
||||||
switch (operators.length) {
|
|
||||||
case 0:
|
|
||||||
query = '';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
var operator = operators[0].operator;
|
|
||||||
query = operators[0].operand;
|
|
||||||
if (!(operator === 'stream' || operator === 'search')) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var invalid = [
|
||||||
|
{operator: 'stream'},
|
||||||
|
{operator: 'is', operand: 'private'},
|
||||||
|
{operator: 'pm-with'},
|
||||||
|
];
|
||||||
|
if (match_criteria(operators, invalid)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var query = last.operand;
|
||||||
var streams = stream_data.subscribed_streams();
|
var streams = stream_data.subscribed_streams();
|
||||||
|
|
||||||
streams = _.filter(streams, function (stream) {
|
streams = _.filter(streams, function (stream) {
|
||||||
@@ -501,8 +499,8 @@ exports.get_suggestions = function (query) {
|
|||||||
suggestions = get_sent_by_me_suggestions(last, base_operators);
|
suggestions = get_sent_by_me_suggestions(last, base_operators);
|
||||||
attach_suggestions(result, base, suggestions);
|
attach_suggestions(result, base, suggestions);
|
||||||
|
|
||||||
suggestions = get_stream_suggestions(operators);
|
suggestions = get_stream_suggestions(last, base_operators);
|
||||||
result = result.concat(suggestions);
|
attach_suggestions(result, base, suggestions);
|
||||||
|
|
||||||
var persons = people.get_all_persons();
|
var persons = people.get_all_persons();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user