From b7910bc7512b8c08e6d4e8233e0d90aab0c7f35d Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 5 Jul 2023 10:32:04 +0200 Subject: [PATCH] Add button to see results for polls in web UI (#25726) --- app/javascript/mastodon/components/poll.jsx | 13 +++++++++---- app/javascript/mastodon/locales/en.json | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/javascript/mastodon/components/poll.jsx b/app/javascript/mastodon/components/poll.jsx index dfc4034fa3..4304f9acd4 100644 --- a/app/javascript/mastodon/components/poll.jsx +++ b/app/javascript/mastodon/components/poll.jsx @@ -130,6 +130,10 @@ class Poll extends ImmutablePureComponent { this.props.refresh(); }; + handleReveal = () => { + this.setState({ revealed: true }); + } + renderOption (option, optionIndex, showResults) { const { poll, lang, disabled, intl } = this.props; const pollVotesCount = poll.get('voters_count') || poll.get('votes_count'); @@ -205,14 +209,14 @@ class Poll extends ImmutablePureComponent { render () { const { poll, intl } = this.props; - const { expired } = this.state; + const { revealed, expired } = this.state; if (!poll) { return null; } const timeRemaining = expired ? intl.formatMessage(messages.closed) : ; - const showResults = poll.get('voted') || expired; + const showResults = poll.get('voted') || revealed || expired; const disabled = this.props.disabled || Object.entries(this.state.selected).every(item => !item); let votesCount = null; @@ -231,9 +235,10 @@ class Poll extends ImmutablePureComponent {
{!showResults && } - {showResults && !this.props.disabled && · } + {!showResults && <> · } + {showResults && !this.props.disabled && <> · } {votesCount} - {poll.get('expires_at') && · {timeRemaining}} + {poll.get('expires_at') && <> · {timeRemaining}}
); diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index b33c8e677e..2afac7e7e8 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -487,6 +487,7 @@ "picture_in_picture.restore": "Put it back", "poll.closed": "Closed", "poll.refresh": "Refresh", + "poll.reveal": "See results", "poll.total_people": "{count, plural, one {# person} other {# people}}", "poll.total_votes": "{count, plural, one {# vote} other {# votes}}", "poll.vote": "Vote",