mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
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:
@@ -189,8 +189,11 @@ export function sort_emojis<T extends Emoji>(objs: T[], query: string): T[] {
|
||||
objs.filter((obj) => obj.is_realm_emoji).map((obj) => obj.emoji_name),
|
||||
);
|
||||
|
||||
const popular_emoji_matches = objs.filter((obj) => is_popular(obj));
|
||||
const others = objs.filter((obj) => !is_popular(obj));
|
||||
const perfect_emoji_matches = objs.filter((obj) => obj.emoji_name === query);
|
||||
const without_perfect_matches = objs.filter((obj) => obj.emoji_name !== query);
|
||||
|
||||
const popular_emoji_matches = without_perfect_matches.filter((obj) => is_popular(obj));
|
||||
const others = without_perfect_matches.filter((obj) => !is_popular(obj));
|
||||
|
||||
const triage_results = triage(query, others, (x) => x.emoji_name);
|
||||
|
||||
@@ -202,6 +205,7 @@ export function sort_emojis<T extends Emoji>(objs: T[], query: string): T[] {
|
||||
}
|
||||
|
||||
const sorted_results_with_possible_duplicates = [
|
||||
...perfect_emoji_matches,
|
||||
...popular_emoji_matches,
|
||||
...prioritise_realm_emojis(triage_results.matches),
|
||||
...prioritise_realm_emojis(triage_results.rest),
|
||||
|
||||
Reference in New Issue
Block a user