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.
This commit is contained in:
Evan Simkowitz 2024-12-12 15:16:34 -08:00 committed by GitHub
parent 247d84e8e8
commit c34f2da0c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);