mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 03:23:50 +00:00
emoji: Abstract all name_to_codepoint, codepoint_to_name accesses.
Computed indexes into these raw objects should be guarded with Object.prototype.hasOwnProperty; make our accessors do this automatically and use them consistently. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
e5e1a05e74
commit
080abf4a1e
@@ -109,10 +109,9 @@ exports.generate_emoji_picker_data = function (realm_emojis) {
|
||||
for (const [category, codepoints] of Object.entries(emoji_codes.emoji_catalog)) {
|
||||
const emojis = [];
|
||||
for (const codepoint of codepoints) {
|
||||
if (emoji_codes.codepoint_to_name.hasOwnProperty(codepoint)) {
|
||||
const emoji_dict = emoji.emojis_by_name.get(
|
||||
emoji_codes.codepoint_to_name[codepoint]
|
||||
);
|
||||
const name = emoji.get_emoji_name(codepoint);
|
||||
if (name !== undefined) {
|
||||
const emoji_dict = emoji.emojis_by_name.get(name);
|
||||
if (emoji_dict !== undefined && emoji_dict.is_realm_emoji !== true) {
|
||||
emojis.push(emoji_dict);
|
||||
}
|
||||
@@ -123,8 +122,9 @@ exports.generate_emoji_picker_data = function (realm_emojis) {
|
||||
|
||||
const popular = [];
|
||||
for (const codepoint of typeahead.popular_emojis) {
|
||||
if (emoji_codes.codepoint_to_name.hasOwnProperty(codepoint)) {
|
||||
const emoji_dict = emoji.emojis_by_name.get(emoji_codes.codepoint_to_name[codepoint]);
|
||||
const name = emoji.get_emoji_name(codepoint);
|
||||
if (name !== undefined) {
|
||||
const emoji_dict = emoji.emojis_by_name.get(name);
|
||||
if (emoji_dict !== undefined) {
|
||||
popular.push(emoji_dict);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user