Skip to content

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.

fix: current page atom (#4515)

Alex Yanga633fb6dead2
diff --git a/packages/sdk/src/entry.ts b/packages/sdk/src/entry.ts
index 2ec3ad7e17..5288cb3260 100644
--- a/packages/sdk/src/entry.ts
+++ b/packages/sdk/src/entry.ts
@@ -60,6 +60,6 @@ export declare const pushLayoutAtom: WritableAtom<
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 rootStore: ReturnType<typeof getDefaultStore>;
diff --git a/plugins/outline/src/app.tsx b/plugins/outline/src/app.tsx
index 1c117d37a8..1f54ad30be 100644
--- a/plugins/outline/src/app.tsx
+++ b/plugins/outline/src/app.tsx
@@ -1,5 +1,6 @@
import {
- currentPageAtom,
+ currentPageIdAtom,
+ currentWorkspaceAtom,
deleteLayoutAtom,
pushLayoutAtom,
} from '@affine/sdk/entry';
@@ -15,7 +16,11 @@ import { createRoot } from 'react-dom/client';
const Outline = () => {
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) {
tocPanelRef.current = new TOCNotesPanel();