diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-03-06 03:57:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 03:57:46 +0100 |
commit | 4407f07014096bcbaf5a06015a5791984282846d (patch) | |
tree | 56be6d068c123835ab733fd0c69c23b4d36bb8e7 /app/javascript | |
parent | efd0fb80880171b1f027b6d0dbd8ace999857062 (diff) |
Render unicode emoji in polls using emoji pack (#10185)
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/mastodon/actions/importer/index.js | 4 | ||||
-rw-r--r-- | app/javascript/mastodon/actions/importer/normalizer.js | 11 | ||||
-rw-r--r-- | app/javascript/mastodon/components/poll.js | 2 |
3 files changed, 14 insertions, 3 deletions
diff --git a/app/javascript/mastodon/actions/importer/index.js b/app/javascript/mastodon/actions/importer/index.js index abadee817..e990dc04c 100644 --- a/app/javascript/mastodon/actions/importer/index.js +++ b/app/javascript/mastodon/actions/importer/index.js @@ -1,4 +1,4 @@ -import { normalizeAccount, normalizeStatus } from './normalizer'; +import { normalizeAccount, normalizeStatus, normalizePoll } from './normalizer'; export const ACCOUNT_IMPORT = 'ACCOUNT_IMPORT'; export const ACCOUNTS_IMPORT = 'ACCOUNTS_IMPORT'; @@ -71,7 +71,7 @@ export function importFetchedStatuses(statuses) { } if (status.poll && status.poll.id) { - pushUnique(polls, status.poll); + pushUnique(polls, normalizePoll(status.poll)); } } diff --git a/app/javascript/mastodon/actions/importer/normalizer.js b/app/javascript/mastodon/actions/importer/normalizer.js index 3085cd537..ea80c0efb 100644 --- a/app/javascript/mastodon/actions/importer/normalizer.js +++ b/app/javascript/mastodon/actions/importer/normalizer.js @@ -67,3 +67,14 @@ export function normalizeStatus(status, normalOldStatus) { return normalStatus; } + +export function normalizePoll(poll) { + const normalPoll = { ...poll }; + + normalPoll.options = poll.options.map(option => ({ + ...option, + title_emojified: emojify(escapeTextContentForBrowser(option.title)), + })); + + return normalPoll; +} diff --git a/app/javascript/mastodon/components/poll.js b/app/javascript/mastodon/components/poll.js index 182491af8..c52445c86 100644 --- a/app/javascript/mastodon/components/poll.js +++ b/app/javascript/mastodon/components/poll.js @@ -120,7 +120,7 @@ class Poll extends ImmutablePureComponent { {!showResults && <span className={classNames('poll__input', { checkbox: poll.get('multiple'), active })} />} {showResults && <span className='poll__number'>{Math.round(percent)}%</span>} - {option.get('title')} + <span dangerouslySetInnerHTML={{ __html: option.get('title_emojified') }} /> </label> </li> ); |