Skip to content

Commit

Permalink
Fix race condition when going to governance and proposals still not f…
Browse files Browse the repository at this point in the history
…etched
  • Loading branch information
vctt94 committed Mar 26, 2020
1 parent 5ce0a06 commit b524eac
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function ProposalList ({ finishedVote, tab }) {
});
const previous = usePrevious({ proposals, tab });
useEffect(() => {
if (!previous || !previous.proposals[tab]) return;
if (!previous || !previous.proposals || !previous.proposals[tab]) return;
if (previous.tab !== tab) return;
// if proposals list is bigger goes to success. This is needed because
// if enabling politeia decrediton gets the inventory and initial batch
Expand All @@ -118,15 +118,14 @@ export function ProposalList ({ finishedVote, tab }) {
}
}, [ proposals ]);

const proposalTab = proposals[tab];
switch (state.value) {
case "idle":
return <NoProposals />;
case "loading":
return <div className="proposal-loading-page"><PoliteiaLoading center /></div>;
case "success":
return (
proposalTab && proposalTab.length
proposals[tab] && proposals[tab].length
? (
<InfiniteScroll
hasMore={!noMoreProposals}
Expand All @@ -136,7 +135,7 @@ export function ProposalList ({ finishedVote, tab }) {
threshold={300}
>
<div className={"proposal-list " + (finishedVote && "ended")}>
{ proposalTab.map(v => <ProposalListItem key={v.token} {...v} />) }
{ proposals[tab].map(v => <ProposalListItem key={v.token} {...v} />) }
</div>
</InfiniteScroll>
) : <NoProposals />
Expand Down

0 comments on commit b524eac

Please sign in to comment.