emoji: Prefix sort for emojis.

Emoji prefix sort for "popular emojis first". Fixes #7625.
This commit is contained in:
Utkarsh Patil
2018-04-22 04:06:19 +05:30
committed by Tim Abbott
parent 59f5af6b62
commit 955d03b8a0
4 changed files with 62 additions and 9 deletions

View File

@@ -254,6 +254,22 @@ exports.prefix_sort = function (query, objs, get_item) {
rest: noMatch };
};
// manipulate prefix_sort to select popular emojis first
// This is kinda a hack and so probably not our long-term solution.
exports.emoji_prefix_sort = function (query, objs, get_item) {
var prefix_sort = exports.prefix_sort(query, objs, get_item);
var popular_emoji_matches = [];
var other_emoji_matches = [];
prefix_sort.matches.forEach(function (obj) {
if (emoji_picker.frequently_used_emojis_list.includes(obj.codepoint)) {
popular_emoji_matches.push(obj);
} else {
other_emoji_matches.push(obj);
}
});
return { matches: popular_emoji_matches.concat(other_emoji_matches), rest: prefix_sort.rest };
};
return exports;
}());