(Fix) Refresh ballot card after voting or finalization
This commit is contained in:
parent
0a42900b62
commit
691d5651ab
|
@ -180,10 +180,23 @@ export class BallotCard extends React.Component {
|
|||
swal("Warning!", messages.INVALID_VOTE_MSG, "warning");
|
||||
return;
|
||||
}
|
||||
this.getContract(contractsStore, votingType).vote(id, choice, contractsStore.votingKey)
|
||||
.on("receipt", (tx) => {
|
||||
const contract = this.getContract(contractsStore, votingType);
|
||||
contract.vote(id, choice, contractsStore.votingKey)
|
||||
.on("receipt", async (tx) => {
|
||||
commonStore.hideLoading();
|
||||
if (tx.status === true || tx.status === '0x1') {
|
||||
const ballotInfo = await contract.getBallotInfo(id, contractsStore.votingKey);
|
||||
|
||||
this.totalVoters = ballotInfo.totalVoters;
|
||||
this.progress = ballotInfo.progress;
|
||||
this.isFinalized = ballotInfo.isFinalized;
|
||||
if (ballotInfo.hasOwnProperty('canBeFinalizedNow')) {
|
||||
this.canBeFinalized = ballotInfo.canBeFinalizedNow;
|
||||
} else {
|
||||
await canBeFinalizedNow();
|
||||
}
|
||||
this.hasAlreadyVoted = true;
|
||||
|
||||
swal("Congratulations!", messages.VOTED_SUCCESS_MSG, "success").then((result) => {
|
||||
push(`${commonStore.rootPath}`);
|
||||
});
|
||||
|
@ -233,6 +246,8 @@ export class BallotCard extends React.Component {
|
|||
.on("receipt", (tx) => {
|
||||
commonStore.hideLoading();
|
||||
if (tx.status === true || tx.status === '0x1') {
|
||||
this.isFinalized = true;
|
||||
this.canBeFinalized = false;
|
||||
swal("Congratulations!", messages.FINALIZED_SUCCESS_MSG, "success").then((result) => {
|
||||
push(`${commonStore.rootPath}`);
|
||||
});
|
||||
|
|
|
@ -52,18 +52,11 @@ export default class VotingToChangeKeys {
|
|||
return this.votingToChangeKeysInstance.methods.nextBallotId().call();
|
||||
}
|
||||
|
||||
votingState(_id) {
|
||||
if (this.doesMethodExist('votingState')) {
|
||||
return this.votingToChangeKeysInstance.methods.votingState(_id).call();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getBallotInfo(_id, _votingKey) {
|
||||
if (this.doesMethodExist('getBallotInfo')) {
|
||||
return this.votingToChangeKeysInstance.methods.getBallotInfo(_id).call();
|
||||
}
|
||||
return null;
|
||||
return this.votingToChangeKeysInstance.methods.votingState(_id).call();
|
||||
}
|
||||
|
||||
hasAlreadyVoted(_id, votingKey) {
|
||||
|
|
|
@ -47,18 +47,11 @@ export default class VotingToChangeMinThreshold {
|
|||
return this.votingToChangeMinThresholdInstance.methods.nextBallotId().call();
|
||||
}
|
||||
|
||||
votingState(_id) {
|
||||
if (this.doesMethodExist('votingState')) {
|
||||
return this.votingToChangeMinThresholdInstance.methods.votingState(_id).call();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getBallotInfo(_id, _votingKey) {
|
||||
if (this.doesMethodExist('getBallotInfo')) {
|
||||
return this.votingToChangeMinThresholdInstance.methods.getBallotInfo(_id, _votingKey).call();
|
||||
}
|
||||
return null;
|
||||
return this.votingToChangeMinThresholdInstance.methods.votingState(_id).call();
|
||||
}
|
||||
|
||||
hasAlreadyVoted(_id, votingKey) {
|
||||
|
|
|
@ -47,18 +47,11 @@ export default class VotingToChangeProxy {
|
|||
return this.votingToChangeProxyInstance.methods.nextBallotId().call();
|
||||
}
|
||||
|
||||
votingState(_id) {
|
||||
if (this.doesMethodExist('votingState')) {
|
||||
return this.votingToChangeProxyInstance.methods.votingState(_id).call();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getBallotInfo(_id, _votingKey) {
|
||||
if (this.doesMethodExist('getBallotInfo')) {
|
||||
return this.votingToChangeProxyInstance.methods.getBallotInfo(_id, _votingKey).call();
|
||||
}
|
||||
return null;
|
||||
return this.votingToChangeProxyInstance.methods.votingState(_id).call();
|
||||
}
|
||||
|
||||
hasAlreadyVoted(_id, votingKey) {
|
||||
|
|
|
@ -259,9 +259,6 @@ class ContractsStore {
|
|||
let votingState;
|
||||
try {
|
||||
votingState = await this[contractType].getBallotInfo(id, this.votingKey);
|
||||
if (!votingState) {
|
||||
votingState = await this[contractType].votingState(id);
|
||||
}
|
||||
votingState = this.fillCardVotingState(votingState, contractType);
|
||||
} catch(e) {
|
||||
console.log(e.message);
|
||||
|
|
Loading…
Reference in New Issue