mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-22 20:41:50 +08:00
fix: getPage with undefined pageId
This commit is contained in:
@@ -28,21 +28,23 @@ export const useLoadPage = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const page = pageId ? workspace?.getPage(pageId) : null;
|
const page = pageId ? workspace?.getPage(pageId) : null;
|
||||||
if (!page) {
|
if (page) {
|
||||||
const savedPageId = workspace.meta.pageMetas[0]?.id;
|
loadPage?.current?.(pageId);
|
||||||
if (savedPageId) {
|
return;
|
||||||
router.push(`/workspace/${currentWorkspaceId}/${savedPageId}`);
|
}
|
||||||
|
|
||||||
|
const savedPageId = workspace.meta.pageMetas[0]?.id;
|
||||||
|
if (savedPageId) {
|
||||||
|
router.push(`/workspace/${currentWorkspaceId}/${savedPageId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
createPage?.current?.()?.then(async pageId => {
|
||||||
|
if (!pageId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
router.push(`/workspace/${currentWorkspaceId}/${pageId}`);
|
||||||
createPage?.current?.()?.then(async pageId => {
|
});
|
||||||
if (!pageId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
router.push(`/workspace/${currentWorkspaceId}/${pageId}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
loadPage?.current?.(pageId);
|
|
||||||
}, [workspace, pageId, loadPage, createPage, router, currentWorkspaceId]);
|
}, [workspace, pageId, loadPage, createPage, router, currentWorkspaceId]);
|
||||||
|
|
||||||
return currentPage?.pageId === pageId ? currentPage : null;
|
return currentPage?.pageId === pageId ? currentPage : null;
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export const AppStateProvider = ({ children }: { children?: ReactNode }) => {
|
|||||||
if (pageId === currentPage?.pageId) {
|
if (pageId === currentPage?.pageId) {
|
||||||
return currentPage;
|
return currentPage;
|
||||||
}
|
}
|
||||||
const page = currentWorkspace?.getPage(pageId) || null;
|
const page = (pageId ? currentWorkspace?.getPage(pageId) : null) || null;
|
||||||
setState(state => ({ ...state, currentPage: page }));
|
setState(state => ({ ...state, currentPage: page }));
|
||||||
return page;
|
return page;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user