about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-05-18 07:55:00 -0500
committerGitHub <noreply@github.com>2018-05-18 07:55:00 -0500
commit81e3ec4d6128ad36c54d265c976727abf944e821 (patch)
tree6ab10eeb911b7cd4486285e0dfa0e33eec15bb94 /app/javascript
parent5d823ee00a5c4e06aec457783499ce0f82558bed (diff)
parent52b2f18b150607f20c246a17ba188c8e78153e35 (diff)
Merge pull request #488 from ThibG/glitch-soc/features/accounts-custom-emoji
[Glitch] Enable custom emojis in profiles
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/flavours/glitch/reducers/accounts.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/javascript/flavours/glitch/reducers/accounts.js b/app/javascript/flavours/glitch/reducers/accounts.js
index e8127a871..86f4970c9 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),
     }));
   }