Skip to content

Commit

Permalink
Render unicode emoji in polls using emoji pack (mastodon#10185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and hiyuki2578 committed Oct 2, 2019
1 parent 68f924a commit 3dbfdca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/javascript/mastodon/actions/importer/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -71,7 +71,7 @@ export function importFetchedStatuses(statuses) {
}

if (status.poll && status.poll.id) {
pushUnique(polls, status.poll);
pushUnique(polls, normalizePoll(status.poll));
}
}

Expand Down
11 changes: 11 additions & 0 deletions app/javascript/mastodon/actions/importer/normalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
Expand Down

0 comments on commit 3dbfdca

Please sign in to comment.