From c34f2da0c0b71d16ddaeb7126ec3a39cd38646ca Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Thu, 12 Dec 2024 15:16:34 -0800 Subject: [PATCH] Fix SwitchWorkspace when no workspaces are saved (#1508) Also cleans up a workspace created with "Create new workspace" if you hit cancel when switching to it. --- emain/emain-window.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/emain/emain-window.ts b/emain/emain-window.ts index 8fb1f1d8c..dd6aab740 100644 --- a/emain/emain-window.ts +++ b/emain/emain-window.ts @@ -301,7 +301,7 @@ export class WaveBrowserWindow extends BaseWindow { // If the workspace is already owned by a window, then we can just call SwitchWorkspace without first prompting the user, since it'll just focus to the other window. const workspaceList = await WorkspaceService.ListWorkspaces(); - if (!workspaceList.find((wse) => wse.workspaceid === workspaceId)?.windowid) { + if (!workspaceList?.find((wse) => wse.workspaceid === workspaceId)?.windowid) { const curWorkspace = await WorkspaceService.GetWorkspace(this.workspaceId); if (showCloseConfirmDialog(curWorkspace)) { const choice = dialog.showMessageBoxSync(this, { @@ -312,6 +312,7 @@ export class WaveBrowserWindow extends BaseWindow { }); if (choice === 0) { console.log("user cancelled switch workspace", this.waveWindowId); + await WorkspaceService.DeleteWorkspace(workspaceId); return; } else if (choice === 1) { console.log("user chose open in new window", this.waveWindowId);