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
refactor(infra): move currentPageAtom to core (#5332)
EYHN9493bd99f9b4
diff --git a/packages/common/infra/src/atom/index.ts b/packages/common/infra/src/atom/index.tsindex 30785f552b..978d7fa366 100644--- a/packages/common/infra/src/atom/index.ts+++ b/packages/common/infra/src/atom/index.ts@@ -4,4 +4,3 @@ export const loadedPluginNameAtom = atom<string[]>([]);export * from './root-store';export * from './settings';-export * from './workspace';diff --git a/packages/common/infra/src/atom/workspace.ts b/packages/common/infra/src/atom/workspace.tsdeleted file mode 100644index 871333c835..0000000000--- a/packages/common/infra/src/atom/workspace.ts+++ /dev/null@@ -1,3 +0,0 @@-import { atom } from 'jotai';--export const currentPageIdAtom = atom<string | null>(null);diff --git a/packages/common/sdk/src/entry.ts b/packages/common/sdk/src/entry.tsindex 7421ebeb1e..2cbda2c265 100644--- a/packages/common/sdk/src/entry.ts+++ b/packages/common/sdk/src/entry.ts@@ -60,6 +60,5 @@ export declare const pushLayoutAtom: WritableAtom<void>;export declare const deleteLayoutAtom: WritableAtom<null, [string], void>;-export declare const currentPageIdAtom: Atom<string | null>;export declare const currentWorkspaceAtom: Atom<Promise<Workspace>>;export declare const rootStore: ReturnType<typeof getDefaultStore>;diff --git a/packages/frontend/core/src/atoms/mode.ts b/packages/frontend/core/src/atoms/mode.tsindex 641f6f8186..3a79f90a75 100644--- a/packages/frontend/core/src/atoms/mode.ts+++ b/packages/frontend/core/src/atoms/mode.ts@@ -1,8 +1,9 @@-import { currentPageIdAtom } from '@toeverything/infra/atom';import { atom } from 'jotai/vanilla';import { pageSettingFamily } from './index';+export const currentPageIdAtom = atom<string | null>(null);+export const currentModeAtom = atom<'page' | 'edgeless'>(get => {const pageId = get(currentPageIdAtom);if (!pageId) {diff --git a/packages/frontend/core/src/components/affine/affine-error-boundary/error-basic/info-logger.tsx b/packages/frontend/core/src/components/affine/affine-error-boundary/error-basic/info-logger.tsxindex d347a99b64..7297885c3d 100644--- a/packages/frontend/core/src/components/affine/affine-error-boundary/error-basic/info-logger.tsx+++ b/packages/frontend/core/src/components/affine/affine-error-boundary/error-basic/info-logger.tsx@@ -2,11 +2,12 @@ import {currentWorkspaceAtom,workspaceListAtom,} from '@affine/workspace/atom';-import { currentPageIdAtom } from '@toeverything/infra/atom';import { useAtomValue } from 'jotai/react';import { useEffect } from 'react';import { useLocation, useParams } from 'react-router-dom';+import { currentPageIdAtom } from '../../../../atoms/mode';+export interface DumpInfoProps {error: any;}diff --git a/packages/frontend/core/src/components/pure/cmdk/data.tsx b/packages/frontend/core/src/components/pure/cmdk/data.tsxindex f3f0003d53..612824d780 100644--- a/packages/frontend/core/src/components/pure/cmdk/data.tsx+++ b/packages/frontend/core/src/components/pure/cmdk/data.tsx@@ -12,7 +12,7 @@ import {useBlockSuitePageMeta,usePageMetaHelper,} from '@toeverything/hooks/use-block-suite-page-meta';-import { currentPageIdAtom, getCurrentStore } from '@toeverything/infra/atom';+import { getCurrentStore } from '@toeverything/infra/atom';import {type AffineCommand,AffineCommandRegistry,@@ -29,6 +29,7 @@ import {recentPageIdsBaseAtom,} from '../../../atoms';import { collectionsCRUDAtom } from '../../../atoms/collections';+import { currentPageIdAtom } from '../../../atoms/mode';import { useNavigateHelper } from '../../../hooks/use-navigate-helper';import { WorkspaceSubPath } from '../../../shared';import { usePageHelper } from '../../blocksuite/block-suite-page-list/utils';diff --git a/packages/frontend/core/src/hooks/current/use-current-page.ts b/packages/frontend/core/src/hooks/current/use-current-page.tsindex 8b16a611c3..66095003d0 100644--- a/packages/frontend/core/src/hooks/current/use-current-page.ts+++ b/packages/frontend/core/src/hooks/current/use-current-page.ts@@ -1,8 +1,9 @@import { waitForCurrentWorkspaceAtom } from '@affine/workspace/atom';import { useBlockSuiteWorkspacePage } from '@toeverything/hooks/use-block-suite-workspace-page';-import { currentPageIdAtom } from '@toeverything/infra/atom';import { useAtomValue } from 'jotai';+import { currentPageIdAtom } from '../../atoms/mode';+export const useCurrentPage = () => {const currentPageId = useAtomValue(currentPageIdAtom);const currentWorkspace = useAtomValue(waitForCurrentWorkspaceAtom);diff --git a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsxindex 99216d5ad5..fb850561b1 100644--- a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx+++ b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx@@ -11,7 +11,7 @@ import type { AffineEditorContainer } from '@blocksuite/presets';import type { Page, Workspace } from '@blocksuite/store';import { useBlockSuitePageMeta } from '@toeverything/hooks/use-block-suite-page-meta';import { useWorkspaceStatus } from '@toeverything/hooks/use-workspace-status';-import { appSettingAtom, currentPageIdAtom } from '@toeverything/infra/atom';+import { appSettingAtom } from '@toeverything/infra/atom';import { useAtom, useAtomValue, useSetAtom } from 'jotai';import {memo,@@ -26,7 +26,7 @@ import type { Map as YMap } from 'yjs';import { setPageModeAtom } from '../../../atoms';import { collectionsCRUDAtom } from '../../../atoms/collections';-import { currentModeAtom } from '../../../atoms/mode';+import { currentModeAtom, currentPageIdAtom } from '../../../atoms/mode';import { AffineErrorBoundary } from '../../../components/affine/affine-error-boundary';import { HubIsland } from '../../../components/affine/hub-island';import { GlobalPageHistoryModal } from '../../../components/affine/page-history-modal';