Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #458 from 0xProject/bugfix/fix-crashing-of-voting-…
Browse files Browse the repository at this point in the history
…page

fix crashing of voting page
  • Loading branch information
DennisSimon authored Jun 13, 2022
2 parents ef7d1f1 + 3ff990f commit c854133
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions ts/pages/governance/vote_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export const VoteIndex: React.FC<VoteIndexProps> = () => {
const [isExpanded, setIsExpanded] = React.useState<boolean>(false);
const [isSubmitted, setIsSubmitted] = React.useState<boolean>(false);
const providerState = useSelector((state: State) => state.providerState);
const [isMounted, setIsMounted] = React.useState(true);

const [email, setEmail] = React.useState<string>('');

Expand All @@ -244,11 +245,24 @@ export const VoteIndex: React.FC<VoteIndexProps> = () => {

React.useEffect(() => {
// tslint:disable-next-line: no-floating-promises
(async () => {
const tallyMap: ZeipTallyMap = await fetchTallysAsync();
setTallys(tallyMap);
})();
}, []);
const runFetchAsync = async () => {
try {
const tallyMap: ZeipTallyMap = await fetchTallysAsync();
if (isMounted) {
setTallys(tallyMap);
}
} catch (e) {
if (isMounted) {
setInterval(runFetchAsync, 200);
}
}
};
// tslint:disable-next-line: no-floating-promises
runFetchAsync();
return () => {
setIsMounted(false);
};
}, [isMounted]);

React.useEffect(() => {
const contract = new ZrxTreasuryContract(GOVERNOR_CONTRACT_ADDRESS.ZRX, providerState.provider);
Expand Down Expand Up @@ -346,8 +360,8 @@ export const VoteIndex: React.FC<VoteIndexProps> = () => {

let sumOfTotalVotingPowerAverage;
if (proposals.length && ZEIP_PROPOSALS.length) {
let sumOfZEIPVotingPower;
let sumOfTreasuryVotingPower;
let sumOfZEIPVotingPower: BigNumber = new BigNumber(0);
let sumOfTreasuryVotingPower: BigNumber = new BigNumber(0);
proposals.forEach((proposal) => {
const tally = {
no: new BigNumber(proposal.againstVotes.toString()),
Expand Down

1 comment on commit c854133

@vercel
Copy link

@vercel vercel bot commented on c854133 Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.