fix: unexpected jump 404 page (#3190)

This commit is contained in:
Alex Yang
2023-07-12 18:18:02 +08:00
parent 1fecb22627
commit c1e53b90a2
2 changed files with 34 additions and 28 deletions

View File

@@ -214,31 +214,6 @@ export const WorkspaceLayoutInner: FC<PropsWithChildren> = ({ children }) => {
}
//#endregion
//#region check if page is valid
useEffect(() => {
if (
typeof router.query.pageId === 'string' &&
router.pathname === '/workspace/[workspaceId]/[pageId]' &&
currentPageId
) {
if (currentPageId !== router.query.pageId) {
setCurrentPageId(router.query.pageId);
} else {
const page =
currentWorkspace.blockSuiteWorkspace.getPage(currentPageId);
if (!page) {
router.push('/404').catch(console.error);
}
}
}
}, [
currentPageId,
currentWorkspace.blockSuiteWorkspace,
router,
setCurrentPageId,
]);
//#endregion
usePassiveWorkspaceEffect(currentWorkspace.blockSuiteWorkspace);
useEffect(() => {