sort_emojis: Prioritize perfect matches above all.

Currently we prioritize (even partial) realm emojis above all.
Including over perfect matches if the emoji is **not** a realm emoji.
The commit changes this behavior to prioritize perfect matches above all,
regardless of emoji category.

close https://github.com/zulip/zulip/issues/27545
This commit is contained in:
kraktus
2023-11-12 17:01:55 +01:00
committed by Tim Abbott
parent 5797381ea2
commit 3de6ec0a59
2 changed files with 20 additions and 6 deletions

View File

@@ -237,8 +237,18 @@ run_test("sort_emojis: prioritise realm emojis", () => {
reaction_type: "realm_emoji",
},
];
assert.deepEqual(typeahead.sort_emojis(emoji_list, "thank you"), [
emoji_list[1],
emoji_list[0],
]);
assert.deepEqual(typeahead.sort_emojis(emoji_list, "thank"), [emoji_list[1], emoji_list[0]]);
});
run_test("sort_emojis: prioritise perfect matches", () => {
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,
reaction_type: "realm_emoji",
},
];
assert.deepEqual(typeahead.sort_emojis(emoji_list, "thank you"), emoji_list);
});