Don't show change calc when other side is 0 (#2543)

This commit is contained in:
Jaco Greeff 2020-04-09 22:15:53 +02:00 committed by GitHub
parent ddb3f03d09
commit ce779c5464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View File

@ -75,7 +75,7 @@ function ReferendumVotes ({ change, className, count, index, isWinning, total, v
<Tooltip
text={
isWinning
? t('That amount this total can be reduced by to change the referendum outcome. This assumes changes to the convictions of the existing votes, with not additional turnout.')
? t('The amount this total can be reduced by to change the referendum outcome. This assumes changes to the convictions of the existing votes, with not additional turnout.')
: t('The amount this total should be increased by to change the referendum outcome. This assumes additional turnout with new votes at 1x conviction.')
}
trigger={trigger}

View File

@ -126,14 +126,18 @@ export function approxChanges (threshold: VoteThreshold, sqrtElectorate: BN, sta
inc = nextInc;
}
// for the cases where we start at 0, we could have a value slightly higher than available,
// cleanup, never having more than the max already available to us
// - When the other vote is zero, it is not useful to show the decrease, since it ends up at all
// - Always ensure that we don't go above max available (generally should be covered by above)
return {
changeAye: isPassing
? BN.min(changeAye, state.votedAye)
: changeAye,
changeNay: isPassing
? changeNay
: BN.min(changeNay, state.votedNay)
changeAye: state.votedNay.isZero()
? ZERO
: isPassing
? BN.min(changeAye, state.votedAye)
: changeAye,
changeNay: state.votedAye.isZero()
? ZERO
: isPassing
? changeNay
: BN.min(changeNay, state.votedNay)
};
}