mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 14:08:23 +00:00
Don't limit search suggestions per category.
We cap the number of overall suggestions at 50, but we don't limit within category, since any limit is arbitrary and can confuse users. (imported from commit 3b18e9ad4b89e5a5485a058a2c0cd5fcca61ed35)
This commit is contained in:
@@ -124,7 +124,7 @@ function highlight_person(query, person) {
|
|||||||
return hilite(query, person.full_name) + " <" + hilite(query, person.email) + ">";
|
return hilite(query, person.full_name) + " <" + hilite(query, person.email) + ">";
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_stream_suggestions(query, max_num) {
|
function get_stream_suggestions(query) {
|
||||||
var streams = subs.subscribed_streams();
|
var streams = subs.subscribed_streams();
|
||||||
|
|
||||||
streams = $.grep(streams, function (stream) {
|
streams = $.grep(streams, function (stream) {
|
||||||
@@ -132,7 +132,6 @@ function get_stream_suggestions(query, max_num) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
streams = typeahead_helper.sorter(query, streams);
|
streams = typeahead_helper.sorter(query, streams);
|
||||||
streams = streams.slice(0, max_num);
|
|
||||||
|
|
||||||
var objs = $.map(streams, function (stream) {
|
var objs = $.map(streams, function (stream) {
|
||||||
var prefix = 'Narrow to stream';
|
var prefix = 'Narrow to stream';
|
||||||
@@ -145,13 +144,12 @@ function get_stream_suggestions(query, max_num) {
|
|||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_person_suggestions(all_people, query, prefix, operator, max_num) {
|
function get_person_suggestions(all_people, query, prefix, operator) {
|
||||||
var people = $.grep(all_people, function (person) {
|
var people = $.grep(all_people, function (person) {
|
||||||
return person_matches_query(person, query);
|
return person_matches_query(person, query);
|
||||||
});
|
});
|
||||||
|
|
||||||
people.sort(typeahead_helper.compare_by_pms);
|
people.sort(typeahead_helper.compare_by_pms);
|
||||||
people = people.slice(0, max_num);
|
|
||||||
|
|
||||||
var objs = $.map(people, function (person) {
|
var objs = $.map(people, function (person) {
|
||||||
var name = highlight_person(query, person);
|
var name = highlight_person(query, person);
|
||||||
@@ -170,7 +168,7 @@ function get_suggestion_based_on_query(search_string, operators) {
|
|||||||
return {description: description, search_string: search_string};
|
return {description: description, search_string: search_string};
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_topic_suggestions(query, query_operators, max_num) {
|
function get_topic_suggestions(query, query_operators) {
|
||||||
if (query_operators.length === 0) {
|
if (query_operators.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -258,8 +256,6 @@ function get_topic_suggestions(query, query_operators, max_num) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
topics = topics.slice(0, max_num);
|
|
||||||
|
|
||||||
// Just use alphabetical order. While recency and read/unreadness of
|
// Just use alphabetical order. While recency and read/unreadness of
|
||||||
// subjects do matter in some contexts, you can get that from the left sidebar,
|
// subjects do matter in some contexts, you can get that from the left sidebar,
|
||||||
// and I'm leaning toward high scannability for autocompletion. I also don't
|
// and I'm leaning toward high scannability for autocompletion. I also don't
|
||||||
@@ -291,18 +287,18 @@ exports.initialize = function () {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
suggestions = get_stream_suggestions(query, 4);
|
suggestions = get_stream_suggestions(query);
|
||||||
result = result.concat(suggestions);
|
result = result.concat(suggestions);
|
||||||
|
|
||||||
var people = page_params.people_list;
|
var people = page_params.people_list;
|
||||||
|
|
||||||
suggestions = get_person_suggestions(people, query, 'Narrow to private messages with', 'pm-with', 4);
|
suggestions = get_person_suggestions(people, query, 'Narrow to private messages with', 'pm-with');
|
||||||
result = result.concat(suggestions);
|
result = result.concat(suggestions);
|
||||||
|
|
||||||
suggestions = get_person_suggestions(people, query, 'Narrow to messages sent by', 'sender', 4);
|
suggestions = get_person_suggestions(people, query, 'Narrow to messages sent by', 'sender');
|
||||||
result = result.concat(suggestions);
|
result = result.concat(suggestions);
|
||||||
|
|
||||||
suggestions = get_topic_suggestions(query, operators, 15);
|
suggestions = get_topic_suggestions(query, operators);
|
||||||
result = result.concat(suggestions);
|
result = result.concat(suggestions);
|
||||||
|
|
||||||
// We can't send typeahead objects, only strings.
|
// We can't send typeahead objects, only strings.
|
||||||
|
|||||||
Reference in New Issue
Block a user