Skip to content

Commit

Permalink
fix(web): workspace or userId being undefined (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaWaite committed Jun 30, 2023
1 parent 07f50b8 commit d676dc2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Expand Up @@ -65,6 +65,7 @@ export default () => {
login();
} else {
if (currentWorkspace || !data || !workspaceId) return;
setCurrentUserId(data?.me?.id);
setCurrentWorkspace(data.me?.myTeam);
navigate(`/dashboard/${workspaceId}`);
}
Expand All @@ -79,6 +80,7 @@ export default () => {
login,
verifySignup,
navigate,
setCurrentUserId,
setCurrentWorkspace,
]);

Expand Down
12 changes: 11 additions & 1 deletion web/src/classic/components/organisms/EarthEditor/Header/hooks.ts
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion web/src/classic/components/pages/Authentication/hooks.ts
Expand Up @@ -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)) {
Expand Down

0 comments on commit d676dc2

Please sign in to comment.