mirror of https://github.com/zulip/zulip.git
emoji: Convert all_realm_emojis from object to Map.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
ab93385106
commit
419666fc31
|
@ -5,7 +5,7 @@ zrequire('people');
|
||||||
zrequire('reactions');
|
zrequire('reactions');
|
||||||
|
|
||||||
set_global('emoji', {
|
set_global('emoji', {
|
||||||
all_realm_emojis: {
|
all_realm_emojis: new Map(Object.entries({
|
||||||
991: {
|
991: {
|
||||||
id: '991',
|
id: '991',
|
||||||
emoji_name: 'realm_emoji',
|
emoji_name: 'realm_emoji',
|
||||||
|
@ -24,7 +24,7 @@ set_global('emoji', {
|
||||||
emoji_url: 'TBD',
|
emoji_url: 'TBD',
|
||||||
deactivated: false,
|
deactivated: false,
|
||||||
},
|
},
|
||||||
},
|
})),
|
||||||
active_realm_emojis: {
|
active_realm_emojis: {
|
||||||
realm_emoji: {
|
realm_emoji: {
|
||||||
id: '991',
|
id: '991',
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// emojis. Emoji picker uses this data to derive data for its own use.
|
// emojis. Emoji picker uses this data to derive data for its own use.
|
||||||
exports.emojis_by_name = new Map();
|
exports.emojis_by_name = new Map();
|
||||||
|
|
||||||
exports.all_realm_emojis = {};
|
exports.all_realm_emojis = new Map();
|
||||||
exports.active_realm_emojis = {};
|
exports.active_realm_emojis = {};
|
||||||
exports.default_emoji_aliases = {};
|
exports.default_emoji_aliases = {};
|
||||||
|
|
||||||
|
@ -19,14 +19,16 @@ exports.update_emojis = function update_emojis(realm_emojis) {
|
||||||
// exports.all_realm_emojis is emptied before adding the realm-specific emoji
|
// exports.all_realm_emojis is emptied before adding the realm-specific emoji
|
||||||
// to it. This makes sure that in case of deletion, the deleted realm_emojis
|
// to it. This makes sure that in case of deletion, the deleted realm_emojis
|
||||||
// don't persist in exports.active_realm_emojis.
|
// don't persist in exports.active_realm_emojis.
|
||||||
exports.all_realm_emojis = {};
|
exports.all_realm_emojis.clear();
|
||||||
exports.active_realm_emojis = {};
|
exports.active_realm_emojis = {};
|
||||||
|
|
||||||
_.each(realm_emojis, function (data) {
|
_.each(realm_emojis, function (data) {
|
||||||
exports.all_realm_emojis[data.id] = {id: data.id,
|
exports.all_realm_emojis.set(data.id, {
|
||||||
emoji_name: data.name,
|
id: data.id,
|
||||||
emoji_url: data.source_url,
|
emoji_name: data.name,
|
||||||
deactivated: data.deactivated};
|
emoji_url: data.source_url,
|
||||||
|
deactivated: data.deactivated,
|
||||||
|
});
|
||||||
if (data.deactivated !== true) {
|
if (data.deactivated !== true) {
|
||||||
exports.active_realm_emojis[data.name] = {id: data.id,
|
exports.active_realm_emojis[data.name] = {id: data.id,
|
||||||
emoji_name: data.name,
|
emoji_name: data.name,
|
||||||
|
|
|
@ -286,7 +286,7 @@ exports.view.insert_new_reaction = function (opts) {
|
||||||
|
|
||||||
if (opts.reaction_type !== 'unicode_emoji') {
|
if (opts.reaction_type !== 'unicode_emoji') {
|
||||||
context.is_realm_emoji = true;
|
context.is_realm_emoji = true;
|
||||||
context.url = emoji.all_realm_emojis[emoji_code].emoji_url;
|
context.url = emoji.all_realm_emojis.get(emoji_code).emoji_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.count = 1;
|
context.count = 1;
|
||||||
|
@ -428,7 +428,7 @@ exports.get_message_reactions = function (message) {
|
||||||
|
|
||||||
if (reaction.reaction_type !== 'unicode_emoji') {
|
if (reaction.reaction_type !== 'unicode_emoji') {
|
||||||
reaction.is_realm_emoji = true;
|
reaction.is_realm_emoji = true;
|
||||||
reaction.url = emoji.all_realm_emojis[reaction.emoji_code].emoji_url;
|
reaction.url = emoji.all_realm_emojis.get(reaction.emoji_code).emoji_url;
|
||||||
}
|
}
|
||||||
if (reaction.user_ids.indexOf(page_params.user_id) !== -1) {
|
if (reaction.user_ids.indexOf(page_params.user_id) !== -1) {
|
||||||
reaction.class = "message_reaction reacted";
|
reaction.class = "message_reaction reacted";
|
||||||
|
|
Loading…
Reference in New Issue