Skip to content

Commit

Permalink
Fix loading behavior when Access Token is absent (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
devleejb authored and minai621 committed Nov 5, 2024
1 parent d636af2 commit d762b36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/hooks/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const useGetUserQuery = () => {
}
}, [dispatch, query.data, query.isError, query.isSuccess]);

return query;
return { ...query, isLoading: query.isLoading || !axiosInterceptorAdded };
};

export const useUpdateUserNicknameMutation = () => {
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/providers/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ interface AuthProviderProps {

function AuthProvider(props: AuthProviderProps) {
const { children } = props;
const { data: user, isSuccess, isLoading, isPending } = useGetUserQuery();
const { data: user, isSuccess, isLoading } = useGetUserQuery();
const shouldChangeNickname = useMemo(
() => isSuccess && !user.nickname,
[isSuccess, user?.nickname]
);
const isAuthLoading = isLoading || isPending;

return (
<AuthContext.Provider value={{ isLoggedIn: isSuccess, isLoading: isAuthLoading }}>
<AuthContext.Provider value={{ isLoggedIn: isSuccess, isLoading }}>
{shouldChangeNickname ? <ChangeNicknameModal open /> : children}
</AuthContext.Provider>
);
Expand Down

0 comments on commit d762b36

Please sign in to comment.