diff --git a/static/js/emoji.js b/static/js/emoji.js index 81de630963..fbc58171a1 100644 --- a/static/js/emoji.js +++ b/static/js/emoji.js @@ -7,19 +7,6 @@ exports.all_realm_emojis = {}; exports.active_realm_emojis = {}; exports.default_emoji_aliases = {}; -// Unfortunately, this list does not currently match on -// alias names like party_popper, simple_smile, and -// hammer_and_wrench. But thumbs_up sorts to the top -// for some other reason. -exports.frequently_used_emojis_list = [ - '1f44d', // +1 - '1f389', // tada - '1f642', // slight_smile - '2764', // heart - '1f6e0', // working_on_it - '1f419', // octopus -]; - const zulip_emoji = { id: 'zulip', emoji_name: 'zulip', diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js index 566d2884e8..0a8899db8f 100644 --- a/static/js/emoji_picker.js +++ b/static/js/emoji_picker.js @@ -1,3 +1,5 @@ +const typeahead = require("../shared/js/typeahead"); + const render_emoji_popover = require('../templates/emoji_popover.hbs'); const render_emoji_popover_content = require('../templates/emoji_popover_content.hbs'); const render_emoji_popover_search_results = require('../templates/emoji_popover_search_results.hbs'); @@ -119,7 +121,7 @@ exports.generate_emoji_picker_data = function (realm_emojis) { }); exports.complete_emoji_catalog.Popular = []; - _.each(emoji.frequently_used_emojis_list, function (codepoint) { + _.each(typeahead.popular_emojis, function (codepoint) { if (emoji_codes.codepoint_to_name.hasOwnProperty(codepoint)) { const emoji_name = emoji_codes.codepoint_to_name[codepoint]; if (emoji.emojis_by_name.hasOwnProperty(emoji_name)) { diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.js index f79b083ae2..b56f1f9ce9 100644 --- a/static/js/typeahead_helper.js +++ b/static/js/typeahead_helper.js @@ -167,7 +167,7 @@ exports.sort_emojis = function (objs, query) { const other_emoji_matches = []; for (const obj of triage_results.matches) { - if (emoji.frequently_used_emojis_list.indexOf(obj.emoji_code) !== -1) { + if (typeahead.popular_emojis.indexOf(obj.emoji_code) !== -1) { popular_emoji_matches.push(obj); } else { other_emoji_matches.push(obj); diff --git a/static/shared/js/typeahead.js b/static/shared/js/typeahead.js index 1d005ab784..1e15b79445 100644 --- a/static/shared/js/typeahead.js +++ b/static/shared/js/typeahead.js @@ -1,3 +1,33 @@ +/* + We hand selected the following emojis a few years + ago to be given extra precedence in our typeahead + algorithms and emoji picker UIs. We call them "popular" + emojis for historical reasons, although we've never + technically measured their popularity (and any + results now would be biased in favor of the ones + below, since they've easier to submit). Nonetheless, it + is often convenient to quickly find these. We can + adjust this list over time; we just need to make + sure it works well with the emoji picker's layout + if you increase the number of them. + + For typeahead we'll favor any of these as long as + the emoji code matches. For example, we'll show the + emoji with code 1f44d at the top of your suggestions + whether you type "+" as a prefix for "+1" + or "th" as a prefix for "thumbs up". The caveat is + that other factors still may matter more, such as + prefix matches trumping "popularity". +*/ +exports.popular_emojis = [ + '1f44d', // +1 + '1f389', // tada + '1f642', // slight_smile + '2764', // heart + '1f6e0', // working_on_it + '1f419', // octopus +]; + const unicode_marks = /\p{M}/gu; exports.remove_diacritics = function (s) {