mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
feat: add createWoresapce function
This commit is contained in:
@@ -47,6 +47,7 @@ export const AppStateProvider = ({
|
||||
const currentWorkspace = await dataCenter.loadWorkspace(
|
||||
dataCenter.workspaces[0].id
|
||||
);
|
||||
console.log('currentWorkspace: ', currentWorkspace);
|
||||
|
||||
setAppState({
|
||||
dataCenter,
|
||||
@@ -138,6 +139,18 @@ export const AppStateProvider = ({
|
||||
});
|
||||
};
|
||||
|
||||
const createWorkspace = async (name: string) => {
|
||||
const { dataCenter } = appState;
|
||||
const workspaceInfo = await dataCenter.createWorkspace({
|
||||
name: name,
|
||||
avatar: 'cccc',
|
||||
});
|
||||
if (workspaceInfo && workspaceInfo.room) {
|
||||
const workspace = await dataCenter.loadWorkspace(workspaceInfo.room);
|
||||
console.log('workspace: ', workspace);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<AppState.Provider
|
||||
value={{
|
||||
@@ -146,6 +159,7 @@ export const AppStateProvider = ({
|
||||
loadPage,
|
||||
loadWorkspace,
|
||||
createEditor,
|
||||
createWorkspace,
|
||||
}}
|
||||
>
|
||||
<DynamicBlocksuite setCreateEditorHandler={setCreateEditorHandler} />
|
||||
|
||||
@@ -9,7 +9,7 @@ import type {
|
||||
|
||||
export type AppStateValue = {
|
||||
dataCenter: DataCenter;
|
||||
user: User | null;
|
||||
user: User | undefined;
|
||||
workspaceList: Workspace[];
|
||||
currentWorkspace: StoreWorkspace;
|
||||
currentWorkspaceId: string;
|
||||
@@ -24,6 +24,7 @@ export type AppStateFunction = {
|
||||
setEditor: (page: EditorContainer) => void;
|
||||
loadWorkspace: (workspaceId: string) => Promise<void>;
|
||||
loadPage: (pageId: string) => void;
|
||||
createWorkspace: (name: string) => Promise<void>;
|
||||
};
|
||||
|
||||
export type AppStateContext = AppStateValue & AppStateFunction;
|
||||
|
||||
Reference in New Issue
Block a user