From 00f176c83918db55ebb9ec059877fc8c258e23b1 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 16 Mar 2021 11:21:59 -0400 Subject: [PATCH] remove workspaces from state after removal from file Signed-off-by: Sebastian Malton --- src/common/workspace-store.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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); + } } }