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(() => {