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