fix: infinite workspace loading (#1432)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
|
import { useAtom, useAtomValue } from 'jotai';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import React, { useCallback } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
openWorkspacesModalAtom,
|
openWorkspacesModalAtom,
|
||||||
} from '../atoms';
|
} from '../atoms';
|
||||||
import { useCurrentUser } from '../hooks/current/use-current-user';
|
import { useCurrentUser } from '../hooks/current/use-current-user';
|
||||||
|
import { useCurrentWorkspace } from '../hooks/current/use-current-workspace';
|
||||||
import { useRouterHelper } from '../hooks/use-router-helper';
|
import { useRouterHelper } from '../hooks/use-router-helper';
|
||||||
import { useWorkspaces, useWorkspacesHelper } from '../hooks/use-workspaces';
|
import { useWorkspaces, useWorkspacesHelper } from '../hooks/use-workspaces';
|
||||||
import { WorkspaceSubPath } from '../shared';
|
import { WorkspaceSubPath } from '../shared';
|
||||||
@@ -37,7 +38,7 @@ export function Modals() {
|
|||||||
const user = useCurrentUser();
|
const user = useCurrentUser();
|
||||||
const workspaces = useWorkspaces();
|
const workspaces = useWorkspaces();
|
||||||
const currentWorkspaceId = useAtomValue(currentWorkspaceIdAtom);
|
const currentWorkspaceId = useAtomValue(currentWorkspaceIdAtom);
|
||||||
const setCurrentWorkspace = useSetAtom(currentWorkspaceIdAtom);
|
const [, setCurrentWorkspace] = useCurrentWorkspace();
|
||||||
const { createLocalWorkspace } = useWorkspacesHelper();
|
const { createLocalWorkspace } = useWorkspacesHelper();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -81,11 +82,13 @@ export function Modals() {
|
|||||||
const id = await createLocalWorkspace(name);
|
const id = await createLocalWorkspace(name);
|
||||||
setOpenCreateWorkspaceModal(false);
|
setOpenCreateWorkspaceModal(false);
|
||||||
setOpenWorkspacesModal(false);
|
setOpenWorkspacesModal(false);
|
||||||
|
setCurrentWorkspace(id);
|
||||||
return jumpToSubPath(id, WorkspaceSubPath.ALL);
|
return jumpToSubPath(id, WorkspaceSubPath.ALL);
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
createLocalWorkspace,
|
createLocalWorkspace,
|
||||||
jumpToSubPath,
|
jumpToSubPath,
|
||||||
|
setCurrentWorkspace,
|
||||||
setOpenCreateWorkspaceModal,
|
setOpenCreateWorkspaceModal,
|
||||||
setOpenWorkspacesModal,
|
setOpenWorkspacesModal,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ export const Modal = (props: ModalProps) => {
|
|||||||
...otherProps
|
...otherProps
|
||||||
} = props;
|
} = props;
|
||||||
const [vertical, horizontal] = wrapperPosition;
|
const [vertical, horizontal] = wrapperPosition;
|
||||||
|
// Fixme: This is a workaround for Mui bug
|
||||||
|
// Refs: https://github.com/mui/material-ui/issues/33748
|
||||||
|
if (!open) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledModal
|
<StyledModal
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
|
|||||||
Reference in New Issue
Block a user