emoji_picker: Improve emoji picker search results.

This sorts the emoji picker's search results using the same
`typehead.sort_emojis` function as the compose typehead.

Resolves #15694.
This commit is contained in:
Vinit Singh 2020-07-08 18:33:33 +05:30 committed by Tim Abbott
parent 6e5fb85ade
commit 8b54cce833
1 changed files with 3 additions and 2 deletions

View File

@ -212,15 +212,16 @@ function filter_emojis() {
for (const alias of emoji_dict.aliases) { for (const alias of emoji_dict.aliases) {
const match = search_terms.every((search_term) => alias.includes(search_term)); const match = search_terms.every((search_term) => alias.includes(search_term));
if (match) { if (match) {
search_results.push({ ...emoji_dict, name: alias }); search_results.push({ ...emoji_dict, emoji_name: alias });
break; // We only need the first matching alias per emoji. break; // We only need the first matching alias per emoji.
} }
} }
} }
} }
const sorted_search_results = typeahead.sort_emojis(search_results, query);
const rendered_search_results = render_emoji_popover_search_results({ const rendered_search_results = render_emoji_popover_search_results({
search_results: search_results, search_results: sorted_search_results,
message_id: message_id, message_id: message_id,
}); });
$('.emoji-search-results').html(rendered_search_results); $('.emoji-search-results').html(rendered_search_results);