mirror of https://github.com/Siphonay/mastodon
[Glitch] Enable custom emojis in profiles
Port 61a9018607
to glitch-soc
This commit is contained in:
parent
4bf43e6f3e
commit
52b2f18b15
|
@ -59,6 +59,11 @@ import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
import escapeTextContentForBrowser from 'escape-html';
|
import escapeTextContentForBrowser from 'escape-html';
|
||||||
import { unescapeHTML } from 'flavours/glitch/util/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) => {
|
const normalizeAccount = (state, account) => {
|
||||||
account = { ...account };
|
account = { ...account };
|
||||||
|
|
||||||
|
@ -66,15 +71,16 @@ const normalizeAccount = (state, account) => {
|
||||||
delete account.following_count;
|
delete account.following_count;
|
||||||
delete account.statuses_count;
|
delete account.statuses_count;
|
||||||
|
|
||||||
|
const emojiMap = makeEmojiMap(account);
|
||||||
const displayName = account.display_name.length === 0 ? account.username : account.display_name;
|
const displayName = account.display_name.length === 0 ? account.username : account.display_name;
|
||||||
account.display_name_html = emojify(escapeTextContentForBrowser(displayName));
|
account.display_name_html = emojify(escapeTextContentForBrowser(displayName), emojiMap);
|
||||||
account.note_emojified = emojify(account.note);
|
account.note_emojified = emojify(account.note, emojiMap);
|
||||||
|
|
||||||
if (account.fields) {
|
if (account.fields) {
|
||||||
account.fields = account.fields.map(pair => ({
|
account.fields = account.fields.map(pair => ({
|
||||||
...pair,
|
...pair,
|
||||||
name_emojified: emojify(escapeTextContentForBrowser(pair.name)),
|
name_emojified: emojify(escapeTextContentForBrowser(pair.name)),
|
||||||
value_emojified: emojify(pair.value),
|
value_emojified: emojify(pair.value, emojiMap),
|
||||||
value_plain: unescapeHTML(pair.value),
|
value_plain: unescapeHTML(pair.value),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue