From f4a64b80913c048cc70ba58a4d888781f699a623 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Thu, 17 May 2018 15:57:16 +0200 Subject: [PATCH] [Glitch] Enable custom emojis in profiles Port 4055ce490c75030c10d847c865d5dfa3814792c6 to glitch-soc --- app/javascript/flavours/glitch/reducers/accounts.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/javascript/flavours/glitch/reducers/accounts.js b/app/javascript/flavours/glitch/reducers/accounts.js index e8127a8713..86f4970c97 100644 --- a/app/javascript/flavours/glitch/reducers/accounts.js +++ b/app/javascript/flavours/glitch/reducers/accounts.js @@ -59,6 +59,11 @@ import { Map as ImmutableMap, fromJS } from 'immutable'; import escapeTextContentForBrowser from 'escape-html'; import { unescapeHTML } from 'flavours/glitch/util/html'; +const makeEmojiMap = record => record.emojis.reduce((obj, emoji) => { + obj[`:${emoji.shortcode}:`] = emoji; + return obj; +}, {}); + const normalizeAccount = (state, account) => { account = { ...account }; @@ -66,15 +71,16 @@ const normalizeAccount = (state, account) => { delete account.following_count; delete account.statuses_count; + const emojiMap = makeEmojiMap(account); const displayName = account.display_name.length === 0 ? account.username : account.display_name; - account.display_name_html = emojify(escapeTextContentForBrowser(displayName)); - account.note_emojified = emojify(account.note); + account.display_name_html = emojify(escapeTextContentForBrowser(displayName), emojiMap); + account.note_emojified = emojify(account.note, emojiMap); if (account.fields) { account.fields = account.fields.map(pair => ({ ...pair, name_emojified: emojify(escapeTextContentForBrowser(pair.name)), - value_emojified: emojify(pair.value), + value_emojified: emojify(pair.value, emojiMap), value_plain: unescapeHTML(pair.value), })); }