fix: first page default mode (#2719)

Co-authored-by: tzhangchi <c@affine.pro>
This commit is contained in:
Himself65
2023-06-08 10:17:27 +08:00
committed by GitHub
parent f3fd5ff76b
commit 05b73a59be
2 changed files with 9 additions and 3 deletions

View File

@@ -1,6 +1,9 @@
import './page-detail-editor.css';
import { PageNotFoundError } from '@affine/env/constant';
import {
DEFAULT_HELLO_WORLD_PAGE_ID,
PageNotFoundError,
} from '@affine/env/constant';
import { rootCurrentEditorAtom } from '@affine/workspace/atom';
import type { EditorContainer } from '@blocksuite/editor';
import type { Page } from '@blocksuite/store';
@@ -61,7 +64,10 @@ const EditorWrapper = memo(function EditorWrapper({
meta => meta.id === pageId
);
const currentMode =
useAtomValue(workspacePreferredModeAtom)[pageId] ?? 'page';
useAtomValue(workspacePreferredModeAtom)[pageId] ??
DEFAULT_HELLO_WORLD_PAGE_ID === pageId
? 'edgeless'
: 'page';
const setEditor = useSetAtom(rootCurrentEditorAtom);
assertExists(meta);
return (

View File

@@ -301,7 +301,7 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {
//#region init workspace
if (currentWorkspace.blockSuiteWorkspace.isEmpty) {
// this is a new workspace, so we should redirect to the new page
const pageId = nanoid();
const pageId = DEFAULT_HELLO_WORLD_PAGE_ID;
const page = currentWorkspace.blockSuiteWorkspace.createPage({
id: pageId,
});