diff --git a/web/src/classic/components/organisms/Authentication/RootPage/hooks.ts b/web/src/classic/components/organisms/Authentication/RootPage/hooks.ts index 4ce92fdc60..26b887eeec 100644 --- a/web/src/classic/components/organisms/Authentication/RootPage/hooks.ts +++ b/web/src/classic/components/organisms/Authentication/RootPage/hooks.ts @@ -65,6 +65,7 @@ export default () => { login(); } else { if (currentWorkspace || !data || !workspaceId) return; + setCurrentUserId(data?.me?.id); setCurrentWorkspace(data.me?.myTeam); navigate(`/dashboard/${workspaceId}`); } @@ -79,6 +80,7 @@ export default () => { login, verifySignup, navigate, + setCurrentUserId, setCurrentWorkspace, ]); diff --git a/web/src/classic/components/organisms/EarthEditor/Header/hooks.ts b/web/src/classic/components/organisms/EarthEditor/Header/hooks.ts index 3fdcb884e4..5c7145dd7f 100644 --- a/web/src/classic/components/organisms/EarthEditor/Header/hooks.ts +++ b/web/src/classic/components/organisms/EarthEditor/Header/hooks.ts @@ -47,7 +47,17 @@ export default () => { skip: !sceneId, }); - const workspaceId = data?.node?.__typename === "Scene" ? data.node.teamId : undefined; + const workspaceId = useMemo( + () => (data?.node?.__typename === "Scene" ? data.node.teamId : undefined), + [data?.node], + ); + + useEffect(() => { + if (!currentWorkspace) { + setCurrentWorkspace(workspaces?.find(w => w.id === workspaceId)); + } + }, [workspaces, workspaceId, currentWorkspace, setCurrentWorkspace]); + const project = useMemo( () => data?.node?.__typename === "Scene" && data.node.project diff --git a/web/src/classic/components/pages/Authentication/hooks.ts b/web/src/classic/components/pages/Authentication/hooks.ts index 4cd839b3d2..5f24a98e92 100644 --- a/web/src/classic/components/pages/Authentication/hooks.ts +++ b/web/src/classic/components/pages/Authentication/hooks.ts @@ -37,8 +37,17 @@ export default () => { useEffect(() => { if (!isAuthenticated || currentWorkspace || !data || !workspaceId) return; + setCurrentUserId(data?.me?.id); setCurrentWorkspace(data.me?.myTeam); - }, [isAuthenticated, navigate, data, workspaceId, currentWorkspace, setCurrentWorkspace]); + }, [ + isAuthenticated, + navigate, + data, + workspaceId, + currentWorkspace, + setCurrentUserId, + setCurrentWorkspace, + ]); useEffect(() => { if (authError || (isAuthenticated && !loading && data?.me === null)) {