Skip to content

Commit 8c10180

Browse files
author
Jalileh
committed
bugs gone!
1 parent 2d3dca6 commit 8c10180

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

.vscode/launch.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

emain/emain-window.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,13 @@ export class WaveBrowserWindow extends BaseWindow {
304304
// 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.
305305
const workspaceList = await WorkspaceService.ListWorkspaces();
306306
if (!workspaceList?.find((wse) => wse.workspaceid === workspaceId)?.windowid) {
307-
const curWorkspace = await WorkspaceService.GetWorkspace(this.workspaceId); /* potential bug here, curWorkspace undefined after deleting previous workspace */
308-
if (curWorkspace && isNonEmptyUnsavedWorkspace(curWorkspace)) {
307+
const curWorkspace = await WorkspaceService.GetWorkspace(this.workspaceId);
308+
if (curWorkspace == undefined) { // @jalileh this occurs when we have already deleted the current workspace
309+
await this._queueActionInternal({ op: "switchworkspace", workspaceId });
310+
return;
311+
}
312+
313+
if (isNonEmptyUnsavedWorkspace(curWorkspace)) {
309314
console.log(
310315
`existing unsaved workspace ${this.workspaceId} has content, opening workspace ${workspaceId} in new window`
311316
);

pkg/wcore/window.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ func SwitchWorkspace(ctx context.Context, windowId string, workspaceId string) (
5252
return nil, fmt.Errorf("error updating window: %w", err)
5353
}
5454

55-
deleted, _, err := DeleteWorkspace(ctx, curWsId, false)
56-
if err != nil {
57-
return nil, fmt.Errorf("error deleting current workspace: %w", err)
55+
deleted, claimableWorkspace, err := DeleteWorkspace(ctx, curWsId, false)
56+
if err != nil && claimableWorkspace != "" { // @jalileh since we are waiting for a workspace switch after deleting the current, the curWsid is already deleted.
57+
return nil, fmt.Errorf("error deleting workspace: %w", err)
5858
}
59+
5960
if !deleted {
6061
log.Printf("current workspace %s was not deleted\n", curWsId)
6162
} else {

pkg/wcore/workspace.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,16 @@ func DeleteWorkspace(ctx context.Context, workspaceId string, force bool) (bool,
151151
}
152152
UnclaimedWorkspace := ""
153153
for _, ws := range workspaces {
154-
if ws.WindowId == "" {
154+
if ws.WindowId == "" && workspaceId != ws.WorkspaceId {
155155
UnclaimedWorkspace = ws.WorkspaceId
156156
break
157157
}
158158
}
159-
if UnclaimedWorkspace == "" {
160-
err = CloseWindow(ctx, windowId, false)
161-
} else {
159+
160+
if UnclaimedWorkspace != "" {
162161
return true, UnclaimedWorkspace, nil
162+
} else {
163+
err = CloseWindow(ctx, windowId, false)
163164
}
164165

165166
if err != nil {

0 commit comments

Comments
 (0)