feat: switch workspace
This commit is contained in:
1 parent
bcb8b9f211
commit
9ef0fe9d06
4 files changed
+18
-15
No files matched your search
@@ -43,10 +43,12 @@ export const AppStateProvider = ({
|
||||
if (dataCenter.workspaces.length === 0) {
|
||||
await createDefaultWorkspace(dataCenter);
|
||||
}
|
||||
|
||||
const currentWorkspace = await dataCenter.loadWorkspace(
|
||||
dataCenter.workspaces[0].id
|
||||
);
|
||||
let currentWorkspace = appState.currentWorkspace;
|
||||
if (!currentWorkspace) {
|
||||
currentWorkspace = await dataCenter.loadWorkspace(
|
||||
dataCenter.workspaces[0].id
|
||||
);
|
||||
}
|
||||
|
||||
setAppState({
|
||||
dataCenter,
|
||||
@@ -104,6 +106,7 @@ export const AppStateProvider = ({
|
||||
};
|
||||
|
||||
const loadWorkspace = async (workspaceId: string) => {
|
||||
console.log('workspaceId: ', workspaceId);
|
||||
const { dataCenter, workspaceList, currentWorkspaceId } = appState;
|
||||
if (!workspaceList.find(v => v.id === workspaceId)) {
|
||||
return;
|
||||
@@ -111,6 +114,8 @@ export const AppStateProvider = ({
|
||||
if (workspaceId === currentWorkspaceId) {
|
||||
return;
|
||||
}
|
||||
const workspace = await dataCenter.loadWorkspace(workspaceId);
|
||||
console.log('workspace: ', workspace);
|
||||
|
||||
setAppState({
|
||||
...appState,
|
||||
|
||||
Reference in new issue
Block a user