-
Notifications
You must be signed in to change notification settings - Fork 60
Add selected votes counts bar - Closes #445 #754
Conversation
9b5488d
to
5155b7f
Compare
fde6742
to
918d54c
Compare
... that shows an error toast if more than 33 delegates selected
918d54c
to
9348eb9
Compare
import style from './votingBar.css'; | ||
|
||
const VotingBar = ({ votes }) => { | ||
const { maxCountOfVotes, maxCountOfVotesInOneTurn } = votingConst; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent verbosity please perform this shorthand assignment while importing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to use it like that, but it doesn't work.
import { maxCountOfVotes, maxCountOfVotesInOneTurn } from '../../constants/voting';
ends up in both maxCountOfVotes
and maxCountOfVotesInOneTurn
being undefined
|
||
const VotingBar = ({ votes }) => { | ||
const { maxCountOfVotes, maxCountOfVotesInOneTurn } = votingConst; | ||
const votedList = Object.keys(votes).filter(key => votes[key].confirmed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a single forEach
loop instead of 3 filter
s and file the lists thought the same iteration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set up a jsperf to see the difference:
https://jsperf.com/multiple-filters-vs-foreach
ForEach is 3 or 4 times faster, but the absolute values of how long it takes on a list of 100 still make the difference negligible.
I like using filter
s for their conciseness and readability.
src/store/middlewares/voting.js
Outdated
const voteCount = Object.keys(votes).filter( | ||
key => votes[key].confirmed !== votes[key].unconfirmed).length; | ||
const currentVote = votes[action.data.username] || { unconfirmed: true, confirmed: false }; | ||
console.log(voteCount, votingConst.maxCountOfVotesInOneTurn, currentVote); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console.log
. It's interesting that you have a log here and eslint
doesn't fail
src/store/middlewares/voting.js
Outdated
key => votes[key].confirmed !== votes[key].unconfirmed).length; | ||
const currentVote = votes[action.data.username] || { unconfirmed: true, confirmed: false }; | ||
console.log(voteCount, votingConst.maxCountOfVotesInOneTurn, currentVote); | ||
if (voteCount === votingConst.maxCountOfVotesInOneTurn + 1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be great if we show a toast for when we exceed 101 overall votes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Vit.
The goal is to add a bar fixed at the bottom of the voting page that displays numbers of votes selected for voting.
I had it previously implemented in Angular and it looked like this:
The original PR was #447
Closes #445