mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 06:28:23 +00:00
Prevent duplicate search suggestions.
(imported from commit b1fb4d40ee76394ee8eee5aec4e292a408806667)
This commit is contained in:
@@ -352,12 +352,17 @@ exports.initialize = function () {
|
|||||||
suggestions = get_topic_suggestions(query, operators);
|
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, so we have to create a map
|
||||||
|
// back to our objects, and we also filter duplicates here.
|
||||||
search_object = {};
|
search_object = {};
|
||||||
|
var final_result = [];
|
||||||
$.each(result, function (idx, obj) {
|
$.each(result, function (idx, obj) {
|
||||||
|
if (!search_object[obj.search_string]) {
|
||||||
search_object[obj.search_string] = obj;
|
search_object[obj.search_string] = obj;
|
||||||
|
final_result.push(obj);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return $.map(result, function (obj) {
|
return $.map(final_result, function (obj) {
|
||||||
return obj.search_string;
|
return obj.search_string;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user