mirror of https://github.com/zulip/zulip.git
parent
249f482b06
commit
aa72b51bca
|
@ -220,3 +220,14 @@ run_test("sort_emojis: remove duplicates", () => {
|
|||
];
|
||||
assert.deepEqual(typeahead.sort_emojis(emoji_list, "tear"), [emoji_list[1], emoji_list[0]]);
|
||||
});
|
||||
|
||||
run_test("sort_emojis: prioritise realm emojis", () => {
|
||||
const emoji_list = [
|
||||
{emoji_name: "thank_you", emoji_code: "1f64f", reaction_type: "unicode_emoji"},
|
||||
{emoji_name: "thank_you_custom", url: "something", is_realm_emoji: true},
|
||||
];
|
||||
assert.deepEqual(typeahead.sort_emojis(emoji_list, "thank you"), [
|
||||
emoji_list[1],
|
||||
emoji_list[0],
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -153,10 +153,17 @@ export function sort_emojis(objs, query) {
|
|||
|
||||
const triage_results = triage(query, others, (x) => x.emoji_name);
|
||||
|
||||
function prioritise_realm_emojis(emojis) {
|
||||
return [
|
||||
...emojis.filter((emoji) => emoji.is_realm_emoji),
|
||||
...emojis.filter((emoji) => !emoji.is_realm_emoji),
|
||||
];
|
||||
}
|
||||
|
||||
const sorted_results_with_possible_duplicates = [
|
||||
...popular_emoji_matches,
|
||||
...triage_results.matches,
|
||||
...triage_results.rest,
|
||||
...prioritise_realm_emojis(triage_results.matches),
|
||||
...prioritise_realm_emojis(triage_results.rest),
|
||||
];
|
||||
// remove unicode emojis with same code but different names
|
||||
const unicode_emoji_codes = new Set();
|
||||
|
|
Loading…
Reference in New Issue