mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 05:25:53 +08:00
fix: ensure return activeWorkspaceId
This commit is contained in:
@@ -9,23 +9,23 @@ const WorkspaceIndex = () => {
|
||||
const router = useRouter();
|
||||
const { currentWorkspaceId, currentWorkspace } = useAppState();
|
||||
const { createPage } = usePageHelper();
|
||||
const { workspaceLoaded } = useEnsureWorkspace();
|
||||
console.log('workspaceLoaded: ', workspaceLoaded);
|
||||
const { workspaceLoaded, activeWorkspaceId } = useEnsureWorkspace();
|
||||
|
||||
useEffect(() => {
|
||||
const initPage = async () => {
|
||||
if (!workspaceLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
const savedPageId = currentWorkspace?.meta.pageMetas[0]?.id;
|
||||
console.log('savedPageId: ', savedPageId);
|
||||
|
||||
if (savedPageId) {
|
||||
router.replace(`/workspace/${currentWorkspaceId}/${savedPageId}`);
|
||||
router.replace(`/workspace/${activeWorkspaceId}/${savedPageId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const pageId = await createPage();
|
||||
router.replace(`/workspace/${currentWorkspaceId}/${pageId}`);
|
||||
router.replace(`/workspace/${activeWorkspaceId}/${pageId}`);
|
||||
};
|
||||
initPage();
|
||||
}, [
|
||||
|
||||
@@ -11,7 +11,6 @@ export const WorkspaceIndex = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (workspaceLoaded) {
|
||||
console.log('workspaceLoaded: ', workspaceLoaded);
|
||||
router.push(`/workspace/${currentWorkspaceId}`);
|
||||
}
|
||||
}, [currentWorkspaceId, router, workspaceLoaded]);
|
||||
|
||||
Reference in New Issue
Block a user