Skip to content

Commit

Permalink
Merge pull request #57 from AudiusProject/jowlee-update-user
Browse files Browse the repository at this point in the history
Don't use cached user from graphql
  • Loading branch information
jowlee authored and michellebrier committed Oct 9, 2023
1 parent fae3340 commit c8f553f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserData, UserVars>(
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol-dashboard/src/store/cache/user/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit c8f553f

Please sign in to comment.