mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
refactor: Move popular_emojis to typeahead library.
I removed a slightly confusing code comment, which I will address in a follow up commit. Basically, "slight smile" still doesn't win over "small airplane" when you search for "sm", which kind of defeats the purpose of having popular_emojis for the typeahead use case. This is a problem with sort_emojis, though, so when the comment was next to the list of popular emojis, it wasn't really actionable.
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user