@ -28,7 +28,6 @@ class Poll extends ImmutablePureComponent {
intl : PropTypes . object . isRequired ,
intl : PropTypes . object . isRequired ,
dispatch : PropTypes . func ,
dispatch : PropTypes . func ,
disabled : PropTypes . bool ,
disabled : PropTypes . bool ,
visible : PropTypes . bool ,
} ;
} ;
state = {
state = {
@ -70,14 +69,13 @@ class Poll extends ImmutablePureComponent {
} ;
} ;
renderOption ( option , optionIndex ) {
renderOption ( option , optionIndex ) {
const { poll , disabled , visible } = this . props ;
const { poll , disabled } = this . props ;
const percent = poll . get ( 'votes_count' ) === 0 ? 0 : ( option . get ( 'votes_count' ) / poll . get ( 'votes_count' ) ) * 100 ;
const percent = poll . get ( 'votes_count' ) === 0 ? 0 : ( option . get ( 'votes_count' ) / poll . get ( 'votes_count' ) ) * 100 ;
const leading = poll . get ( 'options' ) . filterNot ( other => other . get ( 'title' ) === option . get ( 'title' ) ) . every ( other => option . get ( 'votes_count' ) > other . get ( 'votes_count' ) ) ;
const leading = poll . get ( 'options' ) . filterNot ( other => other . get ( 'title' ) === option . get ( 'title' ) ) . every ( other => option . get ( 'votes_count' ) > other . get ( 'votes_count' ) ) ;
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' ) ;
let titleEmojified = option . get ( 'title_emojified' ) ;
if ( ! titleEmojified ) {
if ( ! titleEmojified ) {
const emojiMap = makeEmojiMap ( poll ) ;
const emojiMap = makeEmojiMap ( poll ) ;
titleEmojified = emojify ( escapeTextContentForBrowser ( option . get ( 'title' ) ) , emojiMap ) ;
titleEmojified = emojify ( escapeTextContentForBrowser ( option . get ( 'title' ) ) , emojiMap ) ;
@ -106,7 +104,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 > }
{ visible ? < span dangerouslySetInnerHTML = { { _ _html : titleEmojified } } / > : < span > { String . fromCharCode ( 64 + optionIndex + 1 ) } < / s p a n > }
< span dangerouslySetInnerHTML = { { _ _html : titleEmojified } } / >
< / l a b e l >
< / l a b e l >
< / l i >
< / l i >
) ;
) ;