feat: add createWoresapce function

This commit is contained in:
DiamondThree committed 2023-01-09 17:25:00 +08:00
1 parent 28b2943dc6
commit d6640e0793
5 files changed
+38 -25

No files matched your search

@@ -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} />