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: open non-trash page when open (#2431)

Himself65d80dae8a8931
diff --git a/apps/web/src/components/page-detail-editor.tsx b/apps/web/src/components/page-detail-editor.tsx
index 0042664686..3a75341883 100644
--- a/apps/web/src/components/page-detail-editor.tsx
+++ b/apps/web/src/components/page-detail-editor.tsx
@@ -84,6 +84,7 @@ export const PageDetailEditor: React.FC<PageDetailEditorProps> = ({
page.workspace.setPageMeta(page.id, {
updatedDate: Date.now(),
});
+ localStorage.setItem('last_page_id', page.id);
onLoad?.(page, editor);
},
[onLoad, setEditor]
diff --git a/apps/web/src/pages/index.tsx b/apps/web/src/pages/index.tsx
index d1c0d9b1e6..47927e6226 100644
--- a/apps/web/src/pages/index.tsx
+++ b/apps/web/src/pages/index.tsx
@@ -21,13 +21,19 @@ const IndexPageInner = () => {
return;
}
const lastId = localStorage.getItem('last_workspace_id');
+ const lastPageId = localStorage.getItem('last_page_id');
const targetWorkspace =
(lastId && workspaces.find(({ id }) => id === lastId)) ||
workspaces.at(0);
if (targetWorkspace) {
+ const nonTrashPages =
+ targetWorkspace.blockSuiteWorkspace.meta.pageMetas.filter(
+ ({ trash }) => !trash
+ );
const pageId =
- targetWorkspace.blockSuiteWorkspace.meta.pageMetas.at(0)?.id;
+ nonTrashPages.find(({ id }) => id === lastPageId)?.id ??
+ nonTrashPages.at(0)?.id;
if (pageId) {
logger.debug('Found target workspace. Jump to page', pageId);
void jumpToPage(targetWorkspace.id, pageId, RouteLogic.REPLACE);