Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Refactor voteUrlProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Oct 11, 2017
1 parent 0fc234a commit aeb507b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/components/voteUrlProcessor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const filterObjectPropsWithValue = (object = {}, value) => (

const mapStateToProps = state => ({
votes: state.voting.votes,
voteCount: Object.keys(state.voting.voteLookupStatus || {}).length,
urlVoteCount: Object.keys(state.voting.voteLookupStatus || {}).length,
pending: filterObjectPropsWithValue(state.voting.voteLookupStatus, 'pending'),
downvotes: filterObjectPropsWithValue(state.voting.voteLookupStatus, 'downvotes'),
upvotes: filterObjectPropsWithValue(state.voting.voteLookupStatus, 'upvotes'),
alreadyVoted: filterObjectPropsWithValue(state.voting.voteLookupStatus, 'alreadyVoted'),
Expand Down
12 changes: 4 additions & 8 deletions src/components/voteUrlProcessor/voteUrlProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ export default class VoteUrlProcessor extends React.Component {
}

getProccessedCount() {
return this.props.upvotes.length +
this.props.downvotes.length +
this.props.notFound.length +
this.props.notVotedYet.length +
this.props.alreadyVoted.length;
return this.props.urlVoteCount - this.props.pending.length;
}

render() {
Expand All @@ -46,13 +42,13 @@ export default class VoteUrlProcessor extends React.Component {
};
return (
<div>
{this.getProccessedCount() < this.props.voteCount ?
{this.getProccessedCount() < this.props.urlVoteCount ?
(<div>
<ProgressBar type='linear' mode='determinate'
value={this.getProccessedCount()} max={this.props.voteCount}/>
value={this.getProccessedCount()} max={this.props.urlVoteCount}/>
<div className={styles.center}>
{this.props.t('Processing delegate names: ')}
{this.getProccessedCount()} / {this.props.voteCount}
{this.getProccessedCount()} / {this.props.urlVoteCount}
</div>
</div>) :
(<span>{Object.keys(errorMessages).map(list => (
Expand Down

0 comments on commit aeb507b

Please sign in to comment.