From 135c51a856735294d4b2121f18c46b52bb8aa9c1 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 1 May 2022 10:19:57 -0700 Subject: [PATCH] fix: fix votes count on Misskey polls (#2138) --- src/routes/_components/status/StatusPoll.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/routes/_components/status/StatusPoll.html b/src/routes/_components/status/StatusPoll.html index 37708322..aebf7d9e 100644 --- a/src/routes/_components/status/StatusPoll.html +++ b/src/routes/_components/status/StatusPoll.html @@ -292,13 +292,16 @@ computed: { pollId: ({ originalStatus }) => originalStatus.poll.id, poll: ({ originalStatus, $polls, pollId }) => $polls[pollId] || originalStatus.poll, - options: ({ poll, originalStatusEmojis, $autoplayGifs, votersCount }) => ( + options: ({ poll, originalStatusEmojis, $autoplayGifs, votersOrVotesCount }) => ( poll.options.map(({ title, votes_count: optionsVotesCount }) => ({ title: emojifyText(escapeHtml(title), originalStatusEmojis, $autoplayGifs), - share: votersCount ? Math.round(optionsVotesCount / votersCount * 100) : 0 + share: votersOrVotesCount ? Math.round(optionsVotesCount / votersOrVotesCount * 100) : 0 })) ), votersCount: ({ poll }) => poll.voters_count, + votesCount: ({ poll }) => poll.votes_count, + // Misskey reports the "voters_count" as null, so just use the "votes_count" + votersOrVotesCount: ({ votersCount, votesCount }) => typeof votersCount === 'number' ? votersCount : votesCount, voted: ({ poll }) => poll.voted, multiple: ({ poll }) => poll.multiple, expired: ({ poll }) => poll.expired, @@ -314,8 +317,8 @@ !isStatusInOwnThread && $isMobileSize && !expired ), formDisabled: ({ choices }) => !choices.length, - votesText: ({ votersCount }) => ( - formatIntl('intl.voteCount', { count: votersCount }) + votesText: ({ votersOrVotesCount }) => ( + formatIntl('intl.voteCount', { count: votersOrVotesCount }) ), computedClass: ({ isStatusInNotification, isStatusInOwnThread, loading, shown }) => ( classname(