diff --git a/src/components/status.jsx b/src/components/status.jsx index 16209bd..57886d7 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -923,6 +923,16 @@ function Poll({ poll, readOnly, onUpdate = () => {} }) { const expiresAtDate = !!expiresAt && new Date(expiresAt); + const pollVotesCount = votersCount || votesCount; + let roundPrecision = 0; + if (pollVotesCount <= 1000) { + roundPrecision = 0; + } else if (pollVotesCount <= 10000) { + roundPrecision = 1; + } else if (pollVotesCount <= 100000) { + roundPrecision = 2; + } + return (
{} }) { {voted || expired ? ( options.map((option, i) => { const { title, votesCount: optionVotesCount } = option; - const pollVotesCount = votersCount || votesCount; const percentage = - Math.round((optionVotesCount / pollVotesCount) * 100) || 0; + ((optionVotesCount / pollVotesCount) * 100).toFixed( + roundPrecision, + ) || 0; // check if current poll choice is the leading one const isLeading = optionVotesCount > 0 &&