mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
fix: if jump in [workspace]/index, should manually load workspace
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
import React, { ReactElement, useEffect } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useAppState } from '@/providers/app-state-provider/context';
|
||||
import { useLoadWorkspace } from '@/providers/app-state-provider/hooks';
|
||||
import WorkspaceLayout from '@/components/workspace-layout';
|
||||
|
||||
const WorkspaceIndex = () => {
|
||||
const router = useRouter();
|
||||
const { createPage, currentWorkspaceId, currentWorkspace } = useAppState();
|
||||
const workspace = useLoadWorkspace();
|
||||
const { createPage, currentWorkspaceId } = useAppState();
|
||||
|
||||
useEffect(() => {
|
||||
const initPage = async () => {
|
||||
const savedPageId = currentWorkspace!.meta.pageMetas[0]?.id;
|
||||
if (!workspace) {
|
||||
return;
|
||||
}
|
||||
const savedPageId = workspace!.meta.pageMetas[0]?.id;
|
||||
if (savedPageId) {
|
||||
router.replace(`/workspace/${currentWorkspaceId}/${savedPageId}`);
|
||||
return;
|
||||
@@ -19,7 +24,7 @@ const WorkspaceIndex = () => {
|
||||
router.replace(`/workspace/${currentWorkspaceId}/${pageId}`);
|
||||
};
|
||||
initPage();
|
||||
}, [currentWorkspace, currentWorkspaceId, createPage, router]);
|
||||
}, [workspace, currentWorkspaceId, createPage, router]);
|
||||
|
||||
return <></>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user