mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
feat: create workspace from loading existing exported file (#2122)
Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
@@ -18,7 +18,7 @@ import { useAffineLogOut } from '../hooks/affine/use-affine-log-out';
|
||||
import { useCurrentUser } from '../hooks/current/use-current-user';
|
||||
import { useCurrentWorkspace } from '../hooks/current/use-current-workspace';
|
||||
import { useRouterHelper } from '../hooks/use-router-helper';
|
||||
import { useAppHelper, useWorkspaces } from '../hooks/use-workspaces';
|
||||
import { useWorkspaces } from '../hooks/use-workspaces';
|
||||
import { WorkspaceSubPath } from '../shared';
|
||||
|
||||
const WorkspaceListModal = lazy(() =>
|
||||
@@ -28,7 +28,7 @@ const WorkspaceListModal = lazy(() =>
|
||||
);
|
||||
|
||||
const CreateWorkspaceModal = lazy(() =>
|
||||
import('../components/pure/create-workspace-modal').then(module => ({
|
||||
import('../components/affine/create-workspace-modal').then(module => ({
|
||||
default: module.CreateWorkspaceModal,
|
||||
}))
|
||||
);
|
||||
@@ -69,7 +69,6 @@ export function Modals() {
|
||||
const setWorkspaces = useSetAtom(rootWorkspacesMetadataAtom);
|
||||
const currentWorkspaceId = useAtomValue(currentWorkspaceIdAtom);
|
||||
const [, setCurrentWorkspace] = useCurrentWorkspace();
|
||||
const { createLocalWorkspace } = useAppHelper();
|
||||
const [transitioning, transition] = useTransition();
|
||||
const env = getEnvironment();
|
||||
const onCloseOnboardingModal = useCallback(() => {
|
||||
@@ -134,27 +133,28 @@ export function Modals() {
|
||||
)}
|
||||
onClickLogin={useAffineLogIn()}
|
||||
onClickLogout={useAffineLogOut()}
|
||||
onCreateWorkspace={useCallback(() => {
|
||||
setOpenCreateWorkspaceModal(true);
|
||||
onNewWorkspace={useCallback(() => {
|
||||
setOpenCreateWorkspaceModal('new');
|
||||
}, [setOpenCreateWorkspaceModal])}
|
||||
onAddWorkspace={useCallback(async () => {
|
||||
setOpenCreateWorkspaceModal('add');
|
||||
}, [setOpenCreateWorkspaceModal])}
|
||||
/>
|
||||
</Suspense>
|
||||
<Suspense>
|
||||
<CreateWorkspaceModal
|
||||
open={openCreateWorkspaceModal}
|
||||
mode={openCreateWorkspaceModal}
|
||||
onClose={useCallback(() => {
|
||||
setOpenCreateWorkspaceModal(false);
|
||||
}, [setOpenCreateWorkspaceModal])}
|
||||
onCreate={useCallback(
|
||||
async name => {
|
||||
const id = await createLocalWorkspace(name);
|
||||
async id => {
|
||||
setOpenCreateWorkspaceModal(false);
|
||||
setOpenWorkspacesModal(false);
|
||||
setCurrentWorkspace(id);
|
||||
return jumpToSubPath(id, WorkspaceSubPath.ALL);
|
||||
return jumpToSubPath(id, WorkspaceSubPath.SETTING);
|
||||
},
|
||||
[
|
||||
createLocalWorkspace,
|
||||
jumpToSubPath,
|
||||
setCurrentWorkspace,
|
||||
setOpenCreateWorkspaceModal,
|
||||
|
||||
@@ -11,7 +11,7 @@ const DesktopThemeSync = memo(function DesktopThemeSync() {
|
||||
const lastThemeRef = useRef(theme);
|
||||
if (lastThemeRef.current !== theme) {
|
||||
if (environment.isDesktop && theme) {
|
||||
window.apis?.onThemeChange(theme);
|
||||
window.apis?.ui.handleThemeChange(theme as 'dark' | 'light' | 'system');
|
||||
}
|
||||
lastThemeRef.current = theme;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user