refactor(infra): move currentPageAtom to core (#5332)

Remove `currentPageAtom` from `infra` to `frontend/core.`
This commit is contained in:
EYHN
2023-12-25 03:34:28 +00:00
parent e1bd13a018
commit 9493bd99f9
8 changed files with 10 additions and 11 deletions

View File

@@ -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) {

View File

@@ -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;
}

View File

@@ -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';

View File

@@ -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);

View File

@@ -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';