mirror of https://github.com/zulip/zulip.git
Prevent duplicate search suggestions.
(imported from commit b1fb4d40ee76394ee8eee5aec4e292a408806667)
This commit is contained in:
parent
04e1567ef8
commit
103625d123
|
@ -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;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue