Skip to content

Commit

Permalink
fix: open non-trash page when open (#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 authored May 18, 2023
1 parent 34ff08b commit d80dae8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/web/src/components/page-detail-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 7 additions & 1 deletion apps/web/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

2 comments on commit d80dae8

@vercel
Copy link

@vercel vercel bot commented on d80dae8 May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d80dae8 May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

affine-storybook – ./packages/component

affine-storybook-git-master-toeverything.vercel.app
affine-storybook.vercel.app
affine-storybook-toeverything.vercel.app
storybook.affine.pro

Please # to comment.