mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-01 18:41:50 +03:00
fix: recent pages list doesn't update (#3848)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
parent
c689c08b9a
commit
54d74f6f0b
@ -22,9 +22,7 @@ export const usePageHelper = (blockSuiteWorkspace: BlockSuiteWorkspace) => {
|
|||||||
(id?: string, mode?: 'page' | 'edgeless') => {
|
(id?: string, mode?: 'page' | 'edgeless') => {
|
||||||
const page = createPage(id);
|
const page = createPage(id);
|
||||||
initEmptyPage(page); // we don't need to wait it to be loaded right?
|
initEmptyPage(page); // we don't need to wait it to be loaded right?
|
||||||
if (mode) {
|
setPageMode(page.id, mode || 'page');
|
||||||
setPageMode(page.id, mode);
|
|
||||||
}
|
|
||||||
openPage(blockSuiteWorkspace.id, page.id);
|
openPage(blockSuiteWorkspace.id, page.id);
|
||||||
},
|
},
|
||||||
[blockSuiteWorkspace.id, createPage, openPage, setPageMode]
|
[blockSuiteWorkspace.id, createPage, openPage, setPageMode]
|
||||||
|
@ -14,12 +14,14 @@ import {
|
|||||||
currentWorkspaceIdAtom,
|
currentWorkspaceIdAtom,
|
||||||
getCurrentStore,
|
getCurrentStore,
|
||||||
} from '@toeverything/infra/atom';
|
} from '@toeverything/infra/atom';
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue, useSetAtom } from 'jotai';
|
||||||
import { type ReactElement, useCallback } from 'react';
|
import { type ReactElement, useCallback } from 'react';
|
||||||
import type { LoaderFunction } from 'react-router-dom';
|
import type { LoaderFunction } from 'react-router-dom';
|
||||||
import { redirect } from 'react-router-dom';
|
import { redirect } from 'react-router-dom';
|
||||||
|
|
||||||
import { getUIAdapter } from '../../adapters/workspace';
|
import { getUIAdapter } from '../../adapters/workspace';
|
||||||
|
import { setPageModeAtom } from '../../atoms';
|
||||||
|
import { currentModeAtom } from '../../atoms/mode';
|
||||||
import { useCurrentWorkspace } from '../../hooks/current/use-current-workspace';
|
import { useCurrentWorkspace } from '../../hooks/current/use-current-workspace';
|
||||||
import { useNavigateHelper } from '../../hooks/use-navigate-helper';
|
import { useNavigateHelper } from '../../hooks/use-navigate-helper';
|
||||||
|
|
||||||
@ -31,8 +33,12 @@ const DetailPageImpl = (): ReactElement => {
|
|||||||
assertExists(currentPageId);
|
assertExists(currentPageId);
|
||||||
const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace;
|
const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace;
|
||||||
const collectionManager = useCollectionManager(currentWorkspace.id);
|
const collectionManager = useCollectionManager(currentWorkspace.id);
|
||||||
|
const mode = useAtomValue(currentModeAtom);
|
||||||
|
const setPageMode = useSetAtom(setPageModeAtom);
|
||||||
|
|
||||||
const onLoad = useCallback(
|
const onLoad = useCallback(
|
||||||
(_: Page, editor: EditorContainer) => {
|
(_: Page, editor: EditorContainer) => {
|
||||||
|
setPageMode(currentPageId, mode);
|
||||||
const dispose = editor.slots.pageLinkClicked.on(({ pageId }) => {
|
const dispose = editor.slots.pageLinkClicked.on(({ pageId }) => {
|
||||||
return openPage(blockSuiteWorkspace.id, pageId);
|
return openPage(blockSuiteWorkspace.id, pageId);
|
||||||
});
|
});
|
||||||
@ -49,9 +55,12 @@ const DetailPageImpl = (): ReactElement => {
|
|||||||
[
|
[
|
||||||
blockSuiteWorkspace.id,
|
blockSuiteWorkspace.id,
|
||||||
collectionManager,
|
collectionManager,
|
||||||
|
currentPageId,
|
||||||
currentWorkspace.id,
|
currentWorkspace.id,
|
||||||
jumpToSubPath,
|
jumpToSubPath,
|
||||||
|
mode,
|
||||||
openPage,
|
openPage,
|
||||||
|
setPageMode,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user