Merge pull request #488 from ThibG/glitch-soc/features/accounts-custom-emoji

[Glitch] Enable custom emojis in profiles
signup-info-prompt
David Yip 2018-05-18 07:55:00 -05:00 committed by GitHub
commit 81e3ec4d61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -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),
}));
}