mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-09-22 09:01:02 +03:00
fix: infinite workspace loading (#1432)
This commit is contained in:
parent
0f11b73d93
commit
1011088248
@ -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,
|
||||
]
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user