diff --git a/src/common/workspace-store.ts b/src/common/workspace-store.ts index 818288d5fb..ba4cdcee17 100644 --- a/src/common/workspace-store.ts +++ b/src/common/workspace-store.ts @@ -309,6 +309,9 @@ export class WorkspaceStore extends BaseStore { this.currentWorkspaceId = currentWorkspace; } + const currentWorkspaces = this.workspaces.toJS(); + const newWorkspaceIds = new Set(); + for (const workspaceModel of workspaces) { const oldWorkspace = this.workspaces.get(workspaceModel.id); @@ -317,6 +320,15 @@ export class WorkspaceStore extends BaseStore { } else { this.workspaces.set(workspaceModel.id, new Workspace(workspaceModel)); } + + newWorkspaceIds.add(workspaceModel.id); + } + + // remove deleted workspaces + for (const workspaceId of currentWorkspaces.keys()) { + if (!newWorkspaceIds.has(workspaceId)) { + this.workspaces.delete(workspaceId); + } } }