There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: first page id conflict (#3192)
Alex Yang5b87d90ffe44
diff --git a/apps/web/src/adapters/local/index.tsx b/apps/web/src/adapters/local/index.tsxindex d42d6125c2..e84cfc4758 100644--- a/apps/web/src/adapters/local/index.tsx+++ b/apps/web/src/adapters/local/index.tsx@@ -1,7 +1,7 @@import { DebugLogger } from '@affine/debug';import { initEmptyPage, initPageWithPreloading } from '@affine/env/blocksuite';import {- DEFAULT_HELLO_WORLD_PAGE_ID,+ DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX,DEFAULT_WORKSPACE_NAME,PageNotFoundError,} from '@affine/env/constant';@@ -42,7 +42,7 @@ export const LocalAdapter: WorkspaceAdapter<WorkspaceFlavour.LOCAL> = {);blockSuiteWorkspace.meta.setName(DEFAULT_WORKSPACE_NAME);const page = blockSuiteWorkspace.createPage({- id: DEFAULT_HELLO_WORLD_PAGE_ID,+ id: `${blockSuiteWorkspace.id}-${DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX}`,});if (runtimeConfig.enablePreloading) {initPageWithPreloading(page).catch(err => {diff --git a/apps/web/src/components/page-detail-editor.tsx b/apps/web/src/components/page-detail-editor.tsxindex 773b39fc96..eaf6d44b76 100644--- a/apps/web/src/components/page-detail-editor.tsx+++ b/apps/web/src/components/page-detail-editor.tsx@@ -1,9 +1,6 @@import './page-detail-editor.css';-import {- DEFAULT_HELLO_WORLD_PAGE_ID,- PageNotFoundError,-} from '@affine/env/constant';+import { PageNotFoundError } from '@affine/env/constant';import { rootBlockHubAtom } from '@affine/workspace/atom';import type { EditorContainer } from '@blocksuite/editor';import { assertExists } from '@blocksuite/global/utils';@@ -61,9 +58,7 @@ const EditorWrapper = memo(function EditorWrapper({);const pageSettingAtom = pageSettingFamily(pageId);const pageSetting = useAtomValue(pageSettingAtom);- const currentMode =- pageSetting?.mode ??- (DEFAULT_HELLO_WORLD_PAGE_ID === pageId ? 'edgeless' : 'page');+ const currentMode = pageSetting?.mode ?? 'page';const setBlockHub = useSetAtom(rootBlockHubAtom);const [appSettings] = useAppSetting();diff --git a/apps/web/src/layouts/workspace-layout.tsx b/apps/web/src/layouts/workspace-layout.tsxindex ee6f7abb9b..52e00dba88 100644--- a/apps/web/src/layouts/workspace-layout.tsx+++ b/apps/web/src/layouts/workspace-layout.tsx@@ -11,7 +11,10 @@ import {WorkspaceFallback,} from '@affine/component/workspace';import { initEmptyPage, initPageWithPreloading } from '@affine/env/blocksuite';-import { DEFAULT_HELLO_WORLD_PAGE_ID, isDesktop } from '@affine/env/constant';+import {+ DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX,+ isDesktop,+} from '@affine/env/constant';import { useAFFiNEI18N } from '@affine/i18n/hooks';import {rootBlockHubAtom,@@ -188,7 +191,7 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {// @ts-expect-errorif (currentWorkspace.blockSuiteWorkspace.meta._proxy.isEmpty !== true) {// this is a new workspace, so we should redirect to the new page- const pageId = DEFAULT_HELLO_WORLD_PAGE_ID;+ const pageId = `${currentWorkspace.blockSuiteWorkspace.id}-${DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX}`;if (currentWorkspace.blockSuiteWorkspace.getPage(pageId) === null) {const page = currentWorkspace.blockSuiteWorkspace.createPage({id: pageId,@@ -218,11 +221,11 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {useEffect(() => {const page = currentWorkspace.blockSuiteWorkspace.getPage(- DEFAULT_HELLO_WORLD_PAGE_ID+ `${currentWorkspace.blockSuiteWorkspace.id}-${DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX}`);if (page && page.meta.jumpOnce) {currentWorkspace.blockSuiteWorkspace.meta.setPageMeta(- DEFAULT_HELLO_WORLD_PAGE_ID,+ `${currentWorkspace.blockSuiteWorkspace.id}-${DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX}`,{jumpOnce: false,}diff --git a/packages/env/src/constant.ts b/packages/env/src/constant.tsindex 113cf72a96..cd1671e95e 100644--- a/packages/env/src/constant.ts+++ b/packages/env/src/constant.ts@@ -14,10 +14,9 @@ export const isBrowser = typeof window !== 'undefined';export const isServer = !isBrowser && typeof navigator === 'undefined';export const isDesktop = isBrowser && !!window.appInfo?.electron;//#endregion-export const AFFINE_STORAGE_KEY = 'affine-local-storage-v2';export const DEFAULT_WORKSPACE_NAME = 'Demo Workspace';export const UNTITLED_WORKSPACE_NAME = 'Untitled';-export const DEFAULT_HELLO_WORLD_PAGE_ID = 'hello-world';+export const DEFAULT_HELLO_WORLD_PAGE_ID_SUFFIX = 'hello-world';export const DEFAULT_SORT_KEY = 'updatedDate';export const MessageCode = {