Remove old votes from council (#2193)

This commit is contained in:
Jaco Greeff 2020-01-24 14:40:52 +01:00 committed by GitHub
parent f134b97dc0
commit 40d7926381
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,7 +120,17 @@ class Vote extends TxModal<Props, State> {
(api.query.electionsPhragmen || api.query.elections)
.votesOf<[AccountId[]] & Codec>(accountId)
.then(([existingVotes]): void => {
this.setState({ votes: existingVotes.map((accountId): string => accountId.toString()) });
const { electionsInfo: { candidates, members, runnersUp } } = this.props;
const available = members
.map(([accountId]): string => accountId.toString())
.concat(runnersUp.map(([accountId]): string => accountId.toString()))
.concat(candidates.map((accountId): string => accountId.toString()));
this.setState({
votes: existingVotes
.map((accountId): string => accountId.toString())
.filter((accountId): boolean => available.includes(accountId))
});
});
}
}