From c8f553f12e6fecdd3f52044913b03dfeb7df6020 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Thu, 11 Feb 2021 12:40:38 -0500 Subject: [PATCH] Merge pull request #57 from AudiusProject/jowlee-update-user Don't use cached user from graphql --- .../src/store/cache/user/graph/hooks.ts | 8 ++++---- packages/protocol-dashboard/src/store/cache/user/hooks.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/protocol-dashboard/src/store/cache/user/graph/hooks.ts b/packages/protocol-dashboard/src/store/cache/user/graph/hooks.ts index 24996340eec..6bf785fd73c 100644 --- a/packages/protocol-dashboard/src/store/cache/user/graph/hooks.ts +++ b/packages/protocol-dashboard/src/store/cache/user/graph/hooks.ts @@ -67,7 +67,8 @@ export const useUsers = (status: Status | undefined) => { export const useUser = ( wallet: string, - setStatus: (status: Status) => void + setStatus: (status: Status) => void, + hasUser: boolean ) => { const [didFetch, setDidFetch] = useState(false) const { error: gqlError, data: gqlData } = useQuery( @@ -80,14 +81,13 @@ export const useUser = ( useEffect(() => { setDidFetch(false) }, [wallet, setDidFetch]) - const dispatch = useDispatch() useEffect(() => { - if (!didFetch && gqlData) { + if (!didFetch && !hasUser && gqlData) { setDidFetch(true) dispatch(populateUsers([gqlData.user], setStatus)) } - }, [gqlData, dispatch, setStatus, didFetch, setDidFetch]) + }, [hasUser, gqlData, dispatch, setStatus, didFetch, setDidFetch]) return { error: gqlError diff --git a/packages/protocol-dashboard/src/store/cache/user/hooks.ts b/packages/protocol-dashboard/src/store/cache/user/hooks.ts index eda366177bf..234f5196d3d 100644 --- a/packages/protocol-dashboard/src/store/cache/user/hooks.ts +++ b/packages/protocol-dashboard/src/store/cache/user/hooks.ts @@ -313,7 +313,7 @@ export const useUser = ({ wallet }: UseUserProps): UseUserResponse => { if (status !== Status.Loading && !user) setStatus(Status.Loading) }, [wallet, user, status]) - const { error } = useGraphUser(wallet, setStatus) + const { error } = useGraphUser(wallet, setStatus, !!user) const dispatch = useDispatch() useEffect(() => {