From 55f3bc8fe6280f05922a11b27a05a530bb8344ae Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Fri, 7 Dec 2018 20:25:38 -0500 Subject: [PATCH] do not get events if contracts are not initialized --- app/dapp.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/app/dapp.js b/app/dapp.js index 714e9a8..ad53626 100644 --- a/app/dapp.js +++ b/app/dapp.js @@ -21,24 +21,31 @@ class App extends React.Component { constructor(props) { super(props) } - state = { admin: false }; + state = { + lpAllowance: 0, + fundProfiles: [], + allPledges: [], + needsInit: true + }; componentDidMount(){ EmbarkJS.onReady(async (err) => { getNetworkType().then(async network => { const { environment } = EmbarkJS - const needsInit = await vaultPledgingNeedsInit() - const lpAllowance = await getLpAllowance() - const fundProfiles = await getProfileEvents() - const allPledges = await getAllPledges() - this.setState({ - network, - environment, - needsInit: needsInit === 0, - lpAllowance, - fundProfiles, - allPledges - }) + const isInitialized = await vaultPledgingNeedsInit() + if (!!isInitialized) { + const lpAllowance = await getLpAllowance() + const fundProfiles = await getProfileEvents() + const allPledges = await getAllPledges() + this.setState({ + network, + environment, + needsInit: false, + lpAllowance, + fundProfiles, + allPledges + }) + } }); }); } @@ -74,8 +81,8 @@ class App extends React.Component { return (
- {allPledges && } - {fundProfiles && } + {!!allPledges.length && } + {!!fundProfiles.length && }