mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-27 02:05:50 +03:00
fix: open non-trash page when open (#2431)
This commit is contained in:
parent
34ff08b92b
commit
d80dae8a89
@ -84,6 +84,7 @@ export const PageDetailEditor: React.FC<PageDetailEditorProps> = ({
|
|||||||
page.workspace.setPageMeta(page.id, {
|
page.workspace.setPageMeta(page.id, {
|
||||||
updatedDate: Date.now(),
|
updatedDate: Date.now(),
|
||||||
});
|
});
|
||||||
|
localStorage.setItem('last_page_id', page.id);
|
||||||
onLoad?.(page, editor);
|
onLoad?.(page, editor);
|
||||||
},
|
},
|
||||||
[onLoad, setEditor]
|
[onLoad, setEditor]
|
||||||
|
@ -21,13 +21,19 @@ const IndexPageInner = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const lastId = localStorage.getItem('last_workspace_id');
|
const lastId = localStorage.getItem('last_workspace_id');
|
||||||
|
const lastPageId = localStorage.getItem('last_page_id');
|
||||||
const targetWorkspace =
|
const targetWorkspace =
|
||||||
(lastId && workspaces.find(({ id }) => id === lastId)) ||
|
(lastId && workspaces.find(({ id }) => id === lastId)) ||
|
||||||
workspaces.at(0);
|
workspaces.at(0);
|
||||||
|
|
||||||
if (targetWorkspace) {
|
if (targetWorkspace) {
|
||||||
|
const nonTrashPages =
|
||||||
|
targetWorkspace.blockSuiteWorkspace.meta.pageMetas.filter(
|
||||||
|
({ trash }) => !trash
|
||||||
|
);
|
||||||
const pageId =
|
const pageId =
|
||||||
targetWorkspace.blockSuiteWorkspace.meta.pageMetas.at(0)?.id;
|
nonTrashPages.find(({ id }) => id === lastPageId)?.id ??
|
||||||
|
nonTrashPages.at(0)?.id;
|
||||||
if (pageId) {
|
if (pageId) {
|
||||||
logger.debug('Found target workspace. Jump to page', pageId);
|
logger.debug('Found target workspace. Jump to page', pageId);
|
||||||
void jumpToPage(targetWorkspace.id, pageId, RouteLogic.REPLACE);
|
void jumpToPage(targetWorkspace.id, pageId, RouteLogic.REPLACE);
|
||||||
|
Loading…
Reference in New Issue
Block a user