mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 05:42:30 +03:00
fix: current page atom (#4515)
This commit is contained in:
parent
1b6cd70247
commit
a633fb6dea
@ -60,6 +60,6 @@ export declare const pushLayoutAtom: WritableAtom<
|
|||||||
void
|
void
|
||||||
>;
|
>;
|
||||||
export declare const deleteLayoutAtom: WritableAtom<null, [string], void>;
|
export declare const deleteLayoutAtom: WritableAtom<null, [string], void>;
|
||||||
export declare const currentPageAtom: Atom<Promise<Page>>;
|
export declare const currentPageIdAtom: Atom<string | null>;
|
||||||
export declare const currentWorkspaceAtom: Atom<Promise<Workspace>>;
|
export declare const currentWorkspaceAtom: Atom<Promise<Workspace>>;
|
||||||
export declare const rootStore: ReturnType<typeof getDefaultStore>;
|
export declare const rootStore: ReturnType<typeof getDefaultStore>;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
currentPageAtom,
|
currentPageIdAtom,
|
||||||
|
currentWorkspaceAtom,
|
||||||
deleteLayoutAtom,
|
deleteLayoutAtom,
|
||||||
pushLayoutAtom,
|
pushLayoutAtom,
|
||||||
} from '@affine/sdk/entry';
|
} from '@affine/sdk/entry';
|
||||||
@ -15,7 +16,11 @@ import { createRoot } from 'react-dom/client';
|
|||||||
|
|
||||||
const Outline = () => {
|
const Outline = () => {
|
||||||
const tocPanelRef = useRef<TOCNotesPanel | null>(null);
|
const tocPanelRef = useRef<TOCNotesPanel | null>(null);
|
||||||
const currentPage = useAtomValue(currentPageAtom);
|
const currentPageId = useAtomValue(currentPageIdAtom);
|
||||||
|
assertExists(currentPageId, 'current page id');
|
||||||
|
const currentWorkspace = useAtomValue(currentWorkspaceAtom);
|
||||||
|
const currentPage = currentWorkspace.getPage(currentPageId);
|
||||||
|
assertExists(currentPage, 'current page');
|
||||||
|
|
||||||
if (!tocPanelRef.current) {
|
if (!tocPanelRef.current) {
|
||||||
tocPanelRef.current = new TOCNotesPanel();
|
tocPanelRef.current = new TOCNotesPanel();
|
||||||
|
Loading…
Reference in New Issue
Block a user