Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
fix: force logout when me query returns null (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: rot1024 <[email protected]>
  • Loading branch information
HideBa and rot1024 authored Jun 16, 2021
1 parent ec261a3 commit 339d613
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/pages/TopPage/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default () => {

const [{ currentTeam }, setLocalState] = useLocalState(s => ({ currentTeam: s.currentTeam }));

const { data } = useTeamsQuery({ skip: !isAuthenticated });
const { data, loading } = useTeamsQuery({ skip: !isAuthenticated });
const teamId = currentTeam?.id || data?.me?.myTeam.id;

useEffect(() => {
Expand All @@ -24,10 +24,10 @@ export default () => {
}, [isAuthenticated, navigate, currentTeam, setLocalState, data, teamId]);

useEffect(() => {
if (authError) {
if (authError || (!loading && !data?.me)) {
logout();
}
}, [authError, logout]);
}, [authError, data?.me, loading, logout]);

return {
isLoading,
Expand Down

0 comments on commit 339d613

Please sign in to comment.