For multi-response polls, show the number of people that voted instead of the sum of all votes submitted
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
24ab5cd19a
commit
da1caf93dd
2 changed files with 12 additions and 6 deletions
|
@ -36,6 +36,15 @@ const PollFooter: React.FC<IPollFooter> = ({ poll, showResults, selected }): JSX
|
|||
intl.formatMessage(messages.closed) :
|
||||
<RelativeTimestamp weight='medium' timestamp={poll.expires_at} futureDate />;
|
||||
|
||||
let votesCount = null;
|
||||
|
||||
if (poll.voters_count !== null && poll.voters_count !== undefined) {
|
||||
votesCount = <FormattedMessage id='poll.total_people' defaultMessage='{count, plural, one {# person} other {# people}}' values={{ count: poll.get('voters_count') }} />;
|
||||
} else {
|
||||
votesCount = <FormattedMessage id='poll.total_votes' defaultMessage='{count, plural, one {# vote} other {# votes}}' values={{ count: poll.get('votes_count') }} />;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<Stack space={4} data-testid='poll-footer'>
|
||||
{(!showResults && poll?.multiple) && (
|
||||
|
@ -58,11 +67,7 @@ const PollFooter: React.FC<IPollFooter> = ({ poll, showResults, selected }): JSX
|
|||
)}
|
||||
|
||||
<Text theme='muted' weight='medium'>
|
||||
<FormattedMessage
|
||||
id='poll.total_votes'
|
||||
defaultMessage='{count, plural, one {# vote} other {# votes}}'
|
||||
values={{ count: poll.votes_count }}
|
||||
/>
|
||||
{votesCount}
|
||||
</Text>
|
||||
|
||||
{poll.expires_at && (
|
||||
|
|
|
@ -110,7 +110,8 @@ const PollOption: React.FC<IPollOption> = (props): JSX.Element | null => {
|
|||
|
||||
if (!poll) return null;
|
||||
|
||||
const percent = poll.votes_count === 0 ? 0 : (option.votes_count / poll.votes_count) * 100;
|
||||
const pollVotesCount = poll.voters_count || poll.votes_count;
|
||||
const percent = pollVotesCount === 0 ? 0 : (option.votes_count / pollVotesCount) * 100;
|
||||
const leading = poll.options.filterNot(other => other.title === option.title).every(other => option.votes_count >= other.votes_count);
|
||||
const voted = poll.own_votes?.includes(index);
|
||||
const message = intl.formatMessage(messages.votes, { votes: option.votes_count });
|
||||
|
|
Loading…
Reference in a new issue