diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb
index 7a74c0b7d0..8392afa734 100644
--- a/app/helpers/stream_entries_helper.rb
+++ b/app/helpers/stream_entries_helper.rb
@@ -104,9 +104,19 @@ module StreamEntriesHelper
I18n.t('statuses.content_warning', warning: status.spoiler_text)
end
+ def poll_summary(status)
+ return unless status.poll
+ status.poll.options.map { |o| "[ ] #{o}" }.join("\n")
+ end
+
def status_description(status)
components = [[media_summary(status), status_text_summary(status)].reject(&:blank?).join(' · ')]
- components << status.text if status.spoiler_text.blank?
+
+ if status.spoiler_text.blank?
+ components << status.text
+ components << poll_summary(status)
+ end
+
components.reject(&:blank?).join("\n\n")
end
diff --git a/app/javascript/mastodon/components/poll.js b/app/javascript/mastodon/components/poll.js
index e9124aefa7..182491af86 100644
--- a/app/javascript/mastodon/components/poll.js
+++ b/app/javascript/mastodon/components/poll.js
@@ -118,7 +118,7 @@ class Poll extends ImmutablePureComponent {
/>
{!showResults && }
- {showResults && {Math.floor(percent)}%}
+ {showResults && {Math.round(percent)}%}
{option.get('title')}
@@ -146,7 +146,8 @@ class Poll extends ImmutablePureComponent {
{!showResults && }
{showResults && !this.props.disabled && · }
- · {timeRemaining}
+
+ {poll.get('expires_at') && · {timeRemaining}}
);
diff --git a/app/javascript/styles/mastodon/polls.scss b/app/javascript/styles/mastodon/polls.scss
index f424965594..7c6e61d630 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,
diff --git a/app/models/poll_vote.rb b/app/models/poll_vote.rb
index aec6789686..9ad66bbf8c 100644
--- a/app/models/poll_vote.rb
+++ b/app/models/poll_vote.rb
@@ -23,6 +23,10 @@ class PollVote < ApplicationRecord
delegate :local?, to: :account
+ def object_type
+ :vote
+ end
+
private
def increment_counter_cache
diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb
index b2c92fdc15..b2a5f53e05 100644
--- a/app/serializers/activitypub/note_serializer.rb
+++ b/app/serializers/activitypub/note_serializer.rb
@@ -15,8 +15,8 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
has_one :replies, serializer: ActivityPub::CollectionSerializer, if: :local?
- has_many :poll_loaded_options, key: :one_of, if: :poll_and_not_multiple?
- has_many :poll_loaded_options, key: :any_of, if: :poll_and_multiple?
+ has_many :poll_options, key: :one_of, if: :poll_and_not_multiple?
+ has_many :poll_options, key: :any_of, if: :poll_and_multiple?
attribute :end_time, if: :poll_and_expires?
attribute :closed, if: :poll_and_expired?
@@ -121,8 +121,12 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
object.account.local?
end
- def poll_loaded_options
- object.poll.loaded_options
+ def poll_options
+ if !object.expired? && object.hide_totals?
+ object.poll.unloaded_options
+ else
+ object.poll.loaded_options
+ end
end
def poll_and_multiple?
diff --git a/app/views/stream_entries/_poll.html.haml b/app/views/stream_entries/_poll.html.haml
index 974aff9bda..c7e5e0c63f 100644
--- a/app/views/stream_entries/_poll.html.haml
+++ b/app/views/stream_entries/_poll.html.haml
@@ -1,5 +1,5 @@
-- options = (!poll.expired? && poll.hide_totals?) ? poll.unloaded_options : poll.loaded_options
-- voted = poll.votes.where(account: current_user.account).exists?
+- options = (!poll.expired? && poll.hide_totals?) ? poll.unloaded_options : poll.loaded_options
+- voted = user_signed_in? && poll.votes.where(account: current_account).exists?
- show_results = voted || poll.expired?
.poll
@@ -9,17 +9,21 @@
- if show_results
- percent = 100 * option.votes_count / poll.votes_count
%span.poll__chart{ style: "width: #{percent}%" }
+
%label.poll__text><
- %span.poll__number= percent
+ %span.poll__number= percent.round
= option.title
- else
%label.poll__text><
- %span.poll__input{ class: poll.multiple ? 'checkbox' : nil}><
+ %span.poll__input{ class: poll.multiple? ? 'checkbox' : nil}><
= option.title
.poll__footer
- unless show_results
%button.button.button-secondary{ disabled: true }
= t('statuses.poll.vote')
+
%span= t('statuses.poll.total_votes', count: poll.votes_count)
- ·
- %span= poll.expires_at
+
+ - unless poll.expires_at.nil?
+ ·
+ %span= l poll.expires_at