about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-05 03:51:18 +0100
committerGitHub <noreply@github.com>2019-03-05 03:51:18 +0100
commita198add83bb527c32fa0e01404338562b157da99 (patch)
treec5a507a1e40092b89fe0c8ab6ffe36fa126628f1 /app/javascript
parent0a39c81dd87242feb84da68b8907c3e45620eadf (diff)
Fix various issues in polls (#10165)
* Fix ActivityPub poll results being serialized even with hide_totals

* Fix poll refresh button having a different font size

* Display poll in OpenGraph description

* Fix NoMethodError when serializing votes

Regression from #10158

* Fix polls on public pages being broken for non-logged-in users

* Do not show time remaining if poll has no expiration date
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/components/poll.js5
-rw-r--r--app/javascript/styles/mastodon/polls.scss1
2 files changed, 4 insertions, 2 deletions
diff --git a/app/javascript/mastodon/components/poll.js b/app/javascript/mastodon/components/poll.js
index e9124aefa..182491af8 100644
--- a/app/javascript/mastodon/components/poll.js
+++ b/app/javascript/mastodon/components/poll.js
@@ -118,7 +118,7 @@ class Poll extends ImmutablePureComponent {
           />
 
           {!showResults && <span className={classNames('poll__input', { checkbox: poll.get('multiple'), active })} />}
-          {showResults && <span className='poll__number'>{Math.floor(percent)}%</span>}
+          {showResults && <span className='poll__number'>{Math.round(percent)}%</span>}
 
           {option.get('title')}
         </label>
@@ -146,7 +146,8 @@ class Poll extends ImmutablePureComponent {
         <div className='poll__footer'>
           {!showResults && <button className='button button-secondary' disabled={disabled} onClick={this.handleVote}><FormattedMessage id='poll.vote' defaultMessage='Vote' /></button>}
           {showResults && !this.props.disabled && <span><button className='poll__link' onClick={this.handleRefresh}><FormattedMessage id='poll.refresh' defaultMessage='Refresh' /></button> · </span>}
-          <FormattedMessage id='poll.total_votes' defaultMessage='{count, plural, one {# vote} other {# votes}}' values={{ count: poll.get('votes_count') }} />  · {timeRemaining}
+          <FormattedMessage id='poll.total_votes' defaultMessage='{count, plural, one {# vote} other {# votes}}' values={{ count: poll.get('votes_count') }} />
+          {poll.get('expires_at') && <span> · {timeRemaining}</span>}
         </div>
       </div>
     );
diff --git a/app/javascript/styles/mastodon/polls.scss b/app/javascript/styles/mastodon/polls.scss
index f42496559..7c6e61d63 100644
--- a/app/javascript/styles/mastodon/polls.scss
+++ b/app/javascript/styles/mastodon/polls.scss
@@ -82,6 +82,7 @@
     border: 0;
     color: $dark-text-color;
     text-decoration: underline;
+    font-size: inherit;
 
     &:hover,
     &:focus,