Skip to content

Commit

Permalink
Merge pull request #11 from damianmarti/fix-have-to-refresh-after-signup
Browse files Browse the repository at this point in the history
Fix the need to refresh page after signup to cast vote
  • Loading branch information
yashgo0018 authored Sep 18, 2024
2 parents 18705d2 + 282aabd commit cf2d908
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/nextjs/components/PollDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ export default function PollDetail({ id }: { id: bigint }) {
}, [coordinatorPubKeyResult]);

const castVote = async () => {
if (!poll || stateIndex == null || !coordinatorPubKey || !keypair) return;
if (!poll || stateIndex == null || !coordinatorPubKey || !keypair) {
notification.error("Error casting vote. Please refresh the page and try again.");
return;
}

// check if the votes are valid
if (isAnyInvalid) {
Expand Down
6 changes: 4 additions & 2 deletions packages/nextjs/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ export default function AuthContextProvider({ children }: { children: React.Reac
listener: logs => {
logs.forEach(log => {
if (
log.args._userPubKeyX !== keypair?.pubKey.asContractParam().x ||
log.args._userPubKeyY !== keypair?.pubKey.asContractParam().y
(keypair?.pubKey.asContractParam().x !== undefined &&
log.args._userPubKeyX !== BigInt(keypair?.pubKey.asContractParam().x)) ||
(keypair?.pubKey.asContractParam().y !== undefined &&
log.args._userPubKeyY !== BigInt(keypair?.pubKey.asContractParam().y))
)
return;
refetchIsRegistered();
Expand Down

0 comments on commit cf2d908

Please sign in to comment.