@ -44,6 +44,11 @@ const timeRemainingString = (intl, date, now) => {
return relativeTime ;
return relativeTime ;
} ;
} ;
const makeEmojiMap = record => record . get ( 'emojis' ) . reduce ( ( obj , emoji ) => {
obj [ ` : ${ emoji . get ( 'shortcode' ) } : ` ] = emoji . toJS ( ) ;
return obj ;
} , { } ) ;
export default @ injectIntl
export default @ injectIntl
class Poll extends ImmutablePureComponent {
class Poll extends ImmutablePureComponent {
@ -99,6 +104,12 @@ class Poll extends ImmutablePureComponent {
const active = ! ! this . state . selected [ ` ${ optionIndex } ` ] ;
const active = ! ! this . state . selected [ ` ${ optionIndex } ` ] ;
const showResults = poll . get ( 'voted' ) || poll . get ( 'expired' ) ;
const showResults = poll . get ( 'voted' ) || poll . get ( 'expired' ) ;
let titleEmojified = option . get ( 'title_emojified' ) ;
if ( ! titleEmojified ) {
const emojiMap = makeEmojiMap ( poll ) ;
titleEmojified = emojify ( escapeTextContentForBrowser ( option . get ( 'title' ) ) , emojiMap ) ;
}
return (
return (
< li key = { option . get ( 'title' ) } >
< li key = { option . get ( 'title' ) } >
{ showResults && (
{ showResults && (
@ -122,7 +133,7 @@ class Poll extends ImmutablePureComponent {
{ ! showResults && < span className = { classNames ( 'poll__input' , { checkbox : poll . get ( 'multiple' ) , active } ) } / > }
{ ! showResults && < span className = { classNames ( 'poll__input' , { checkbox : poll . get ( 'multiple' ) , active } ) } / > }
{ showResults && < span className = 'poll__number' > { Math . round ( percent ) } % < / s p a n > }
{ showResults && < span className = 'poll__number' > { Math . round ( percent ) } % < / s p a n > }
< span dangerouslySetInnerHTML = { { _ _html : option. get ( 'title_emojified' , emojify ( escapeTextContentForBrowser ( option . get ( 'title' ) ) ) ) } } / >
< span dangerouslySetInnerHTML = { { _ _html : titleEmojified } } / >
< / l a b e l >
< / l a b e l >
< / l i >
< / l i >
) ;
) ;