From 327beb7b9089638b98db074d166175055f9d4d82 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Mon, 7 Oct 2019 13:59:11 -0400 Subject: [PATCH] add null checks for incoming data --- src/components/projects/hooks.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/projects/hooks.js b/src/components/projects/hooks.js index 99c3dbd..11bca96 100644 --- a/src/components/projects/hooks.js +++ b/src/components/projects/hooks.js @@ -10,7 +10,7 @@ import { getDelegatePledgesByProfile } from '../../actions/delegates' const callOrderFns = [getFilesWeb, getFilesWebTheGraph, getFiles] async function getProjectAge(data, setState){ - if (data.profile) { + if (data && data.profile) { setState(timeSinceBlock(data.profile.creationTime, 'days')) } else { setState(timeSinceBlock(false, 'days')) @@ -18,7 +18,7 @@ async function getProjectAge(data, setState){ } async function getProjectCreator(data, setState){ - if (!data.profile) return + if (!data || !data.profile) return const { addr } = data.profile setState(addr) } @@ -37,7 +37,7 @@ async function tryIpfsGets(CID, setState, index=0){ } async function getProjectAssets(data, setState, debug=false){ - if (!data.profile) return + if (!data || !data.profile) return const { profile: { url } } = data const CID = url.split('/').slice(-1)[0] if (debug) console.log({CID, data, ipfs}) @@ -112,7 +112,7 @@ const getProjectManifest = (data, assets) => { } async function getAuthorization(data, setState) { - if (!data.profile) return + if (!data || !data.profile) return const { profile: { projectInfo: { goalToken } } } = data const allowance = await getAllowanceFromAddress(goalToken) setState(allowance)