fix: type error

This commit is contained in:
QiShaoXuan
2023-01-10 14:22:08 +08:00
parent a80e15042a
commit e208ab6033
2 changed files with 10 additions and 10 deletions

View File

@@ -28,12 +28,9 @@ export const AppStateProvider = ({
if (dataCenter.workspaces.length === 0) { if (dataCenter.workspaces.length === 0) {
await createDefaultWorkspace(dataCenter); await createDefaultWorkspace(dataCenter);
} }
let currentWorkspace = appState.currentWorkspace; const currentWorkspace = await dataCenter.loadWorkspace(
if (!currentWorkspace) {
currentWorkspace = await dataCenter.loadWorkspace(
dataCenter.workspaces[0].id dataCenter.workspaces[0].id
); );
}
const currentMetaWorkSpace = dataCenter.workspaces.find(item => { const currentMetaWorkSpace = dataCenter.workspaces.find(item => {
return item.id === currentWorkspace.room; return item.id === currentWorkspace.room;
}); });
@@ -53,7 +50,7 @@ export const AppStateProvider = ({
}; };
init(); init();
}, [appState.currentWorkspace]); }, []);
useEffect(() => { useEffect(() => {
if (!appState?.currentWorkspace) { if (!appState?.currentWorkspace) {
@@ -116,6 +113,9 @@ export const AppStateProvider = ({
currentWorkspace: workspace, currentWorkspace: workspace,
currentWorkspaceId: workspaceId, currentWorkspaceId: workspaceId,
currentMetaWorkSpace: currentMetaWorkSpace ?? null, currentMetaWorkSpace: currentMetaWorkSpace ?? null,
pageList: currentWorkspace.meta.pageMetas as PageMeta[],
currentPage: null,
editor: null,
}); });
return workspace; return workspace;

View File

@@ -1,4 +1,4 @@
import { DataCenter, User, Workspace } from '@affine/datacenter'; import { DataCenter, User, WorkspaceInfo } from '@affine/datacenter';
import type { EditorContainer } from '@blocksuite/editor'; import type { EditorContainer } from '@blocksuite/editor';
import type { import type {
@@ -18,9 +18,9 @@ export interface PageMeta extends StorePageMeta {
export type AppStateValue = { export type AppStateValue = {
dataCenter: DataCenter; dataCenter: DataCenter;
user: User | null; user: User | null;
workspaceList: Workspace[]; workspaceList: WorkspaceInfo[];
currentWorkspace: StoreWorkspace; currentWorkspace: StoreWorkspace;
currentMetaWorkSpace: Workspace | null; currentMetaWorkSpace: WorkspaceInfo | null;
currentWorkspaceId: string; currentWorkspaceId: string;
pageList: PageMeta[]; pageList: PageMeta[];
currentPage: StorePage | null; currentPage: StorePage | null;