fix: infinite workspace loading (#1432)

This commit is contained in:
Himself65 2023-03-08 22:31:01 -06:00 committed by GitHub
parent 0f11b73d93
commit 1011088248
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
import { useAtom, useAtomValue } from 'jotai';
import dynamic from 'next/dynamic';
import { useRouter } from 'next/router';
import React, { useCallback } from 'react';
@ -9,6 +9,7 @@ import {
openWorkspacesModalAtom,
} from '../atoms';
import { useCurrentUser } from '../hooks/current/use-current-user';
import { useCurrentWorkspace } from '../hooks/current/use-current-workspace';
import { useRouterHelper } from '../hooks/use-router-helper';
import { useWorkspaces, useWorkspacesHelper } from '../hooks/use-workspaces';
import { WorkspaceSubPath } from '../shared';
@ -37,7 +38,7 @@ export function Modals() {
const user = useCurrentUser();
const workspaces = useWorkspaces();
const currentWorkspaceId = useAtomValue(currentWorkspaceIdAtom);
const setCurrentWorkspace = useSetAtom(currentWorkspaceIdAtom);
const [, setCurrentWorkspace] = useCurrentWorkspace();
const { createLocalWorkspace } = useWorkspacesHelper();
return (
@ -81,11 +82,13 @@ export function Modals() {
const id = await createLocalWorkspace(name);
setOpenCreateWorkspaceModal(false);
setOpenWorkspacesModal(false);
setCurrentWorkspace(id);
return jumpToSubPath(id, WorkspaceSubPath.ALL);
},
[
createLocalWorkspace,
jumpToSubPath,
setCurrentWorkspace,
setOpenCreateWorkspaceModal,
setOpenWorkspacesModal,
]

View File

@ -36,6 +36,12 @@ export const Modal = (props: ModalProps) => {
...otherProps
} = props;
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 (
<StyledModal
{...otherProps}