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:
Anders Kaseorg
2020-05-26 19:17:29 -07:00
committed by Tim Abbott
parent e5e1a05e74
commit 080abf4a1e
6 changed files with 51 additions and 68 deletions

View File

@@ -1,5 +1,3 @@
const emoji_codes = require("../generated/emoji/emoji_codes.json");
function do_narrow_action(action) {
action(current_msg_list.selected_id(), {trigger: 'hotkey'});
return true;
@@ -731,7 +729,7 @@ exports.process_hotkey = function (e, hotkey) {
case 'thumbs_up_emoji': { // '+': reacts with thumbs up emoji on selected message
// Use canonical name.
const thumbs_up_emoji_code = '1f44d';
const canonical_name = emoji_codes.codepoint_to_name[thumbs_up_emoji_code];
const canonical_name = emoji.get_emoji_name(thumbs_up_emoji_code);
reactions.toggle_emoji_reaction(msg.id, canonical_name);
return true;
}