Skip to content

Commit 4407f07

Browse files
authored
Render unicode emoji in polls using emoji pack (#10185)
1 parent efd0fb8 commit 4407f07

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

app/javascript/mastodon/actions/importer/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { normalizeAccount, normalizeStatus } from './normalizer';
1+
import { normalizeAccount, normalizeStatus, normalizePoll } from './normalizer';
22

33
export const ACCOUNT_IMPORT = 'ACCOUNT_IMPORT';
44
export const ACCOUNTS_IMPORT = 'ACCOUNTS_IMPORT';
@@ -71,7 +71,7 @@ export function importFetchedStatuses(statuses) {
7171
}
7272

7373
if (status.poll && status.poll.id) {
74-
pushUnique(polls, status.poll);
74+
pushUnique(polls, normalizePoll(status.poll));
7575
}
7676
}
7777

app/javascript/mastodon/actions/importer/normalizer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,14 @@ export function normalizeStatus(status, normalOldStatus) {
6767

6868
return normalStatus;
6969
}
70+
71+
export function normalizePoll(poll) {
72+
const normalPoll = { ...poll };
73+
74+
normalPoll.options = poll.options.map(option => ({
75+
...option,
76+
title_emojified: emojify(escapeTextContentForBrowser(option.title)),
77+
}));
78+
79+
return normalPoll;
80+
}

app/javascript/mastodon/components/poll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Poll extends ImmutablePureComponent {
120120
{!showResults && <span className={classNames('poll__input', { checkbox: poll.get('multiple'), active })} />}
121121
{showResults && <span className='poll__number'>{Math.round(percent)}%</span>}
122122

123-
{option.get('title')}
123+
<span dangerouslySetInnerHTML={{ __html: option.get('title_emojified') }} />
124124
</label>
125125
</li>
126126
);

0 commit comments

Comments
 (0)