mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 06:16:59 +08:00
refactor(core): remove jump once (#6733)
Previously, we marked `jumpOnce: true` on `doc.meta` to open a specific doc after creating a new workspace. This pr removes `jumpOnce` and directly jumps to the specific doc URL. This PR also fixes an error when opening the all-page page, because the all-page page scans the jumpOnce attribute of all docs, and the code in it will fail on damaged data.
This commit is contained in:
@@ -259,7 +259,7 @@ export const AllWorkspaceModals = (): ReactElement => {
|
||||
openCreateWorkspaceModalAtom
|
||||
);
|
||||
|
||||
const { jumpToSubPath } = useNavigateHelper();
|
||||
const { jumpToSubPath, jumpToPage } = useNavigateHelper();
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -270,15 +270,19 @@ export const AllWorkspaceModals = (): ReactElement => {
|
||||
setOpenCreateWorkspaceModal(false);
|
||||
}, [setOpenCreateWorkspaceModal])}
|
||||
onCreate={useCallback(
|
||||
id => {
|
||||
(id, defaultDocId) => {
|
||||
setOpenCreateWorkspaceModal(false);
|
||||
// if jumping immediately, the page may stuck in loading state
|
||||
// not sure why yet .. here is a workaround
|
||||
setTimeout(() => {
|
||||
jumpToSubPath(id, WorkspaceSubPath.ALL);
|
||||
if (!defaultDocId) {
|
||||
jumpToSubPath(id, WorkspaceSubPath.ALL);
|
||||
} else {
|
||||
jumpToPage(id, defaultDocId);
|
||||
}
|
||||
});
|
||||
},
|
||||
[jumpToSubPath, setOpenCreateWorkspaceModal]
|
||||
[jumpToPage, jumpToSubPath, setOpenCreateWorkspaceModal]
|
||||
)}
|
||||
/>
|
||||
</Suspense>
|
||||
|
||||
Reference in New Issue
Block a user