Browse Source

Render unicode emoji in polls using emoji pack (#10185)

pull/4/head
Eugen Rochko 5 years ago
committed by GitHub
parent
commit
4407f07014
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions
  1. +2
    -2
      app/javascript/mastodon/actions/importer/index.js
  2. +11
    -0
      app/javascript/mastodon/actions/importer/normalizer.js
  3. +1
    -1
      app/javascript/mastodon/components/poll.js

+ 2
- 2
app/javascript/mastodon/actions/importer/index.js View File

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

+ 11
- 0
app/javascript/mastodon/actions/importer/normalizer.js View File

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

+ 1
- 1
app/javascript/mastodon/components/poll.js View File

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

Loading…
Cancel
Save