@@ -294,27 +294,34 @@ export class WaveBrowserWindow extends BaseWindow {
294
294
console . log ( "switchWorkspace already on this workspace" , this . waveWindowId ) ;
295
295
return ;
296
296
}
297
- const curWorkspace = await WorkspaceService . GetWorkspace ( this . workspaceId ) ;
298
- if ( curWorkspace . tabids . length > 1 && ( ! curWorkspace . name || ! curWorkspace . icon ) ) {
299
- const choice = dialog . showMessageBoxSync ( this , {
300
- type : "question" ,
301
- buttons : [ "Cancel" , "Open in New Window" , "Yes" ] ,
302
- title : "Confirm" ,
303
- message :
304
- "This window has unsaved tabs, switching workspaces will delete the existing tabs. Would you like to continue?" ,
305
- } ) ;
306
- if ( choice === 0 ) {
307
- console . log ( "user cancelled switch workspace" , this . waveWindowId ) ;
308
- return ;
309
- } else if ( choice === 1 ) {
310
- console . log ( "user chose open in new window" , this . waveWindowId ) ;
311
- const newWin = await WindowService . CreateWindow ( null , workspaceId ) ;
312
- if ( ! newWin ) {
313
- console . log ( "error creating new window" , this . waveWindowId ) ;
297
+
298
+ // 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.
299
+ const workspaceList = await WorkspaceService . ListWorkspaces ( ) ;
300
+ if ( ! workspaceList . find ( ( wse ) => wse . workspaceid === workspaceId ) ?. windowid ) {
301
+ const curWorkspace = await WorkspaceService . GetWorkspace ( this . workspaceId ) ;
302
+ if ( curWorkspace . tabids . length > 1 && ( ! curWorkspace . name || ! curWorkspace . icon ) ) {
303
+ const choice = dialog . showMessageBoxSync ( this , {
304
+ type : "question" ,
305
+ buttons : [ "Cancel" , "Open in New Window" , "Yes" ] ,
306
+ title : "Confirm" ,
307
+ message :
308
+ "This window has unsaved tabs, switching workspaces will delete the existing tabs. Would you like to continue?" ,
309
+ } ) ;
310
+ if ( choice === 0 ) {
311
+ console . log ( "user cancelled switch workspace" , this . waveWindowId ) ;
312
+ return ;
313
+ } else if ( choice === 1 ) {
314
+ console . log ( "user chose open in new window" , this . waveWindowId ) ;
315
+ const newWin = await WindowService . CreateWindow ( null , workspaceId ) ;
316
+ if ( ! newWin ) {
317
+ console . log ( "error creating new window" , this . waveWindowId ) ;
318
+ }
319
+ const newBwin = await createBrowserWindow ( newWin , await FileService . GetFullConfig ( ) , {
320
+ unamePlatform,
321
+ } ) ;
322
+ newBwin . show ( ) ;
323
+ return ;
314
324
}
315
- const newBwin = await createBrowserWindow ( newWin , await FileService . GetFullConfig ( ) , { unamePlatform } ) ;
316
- newBwin . show ( ) ;
317
- return ;
318
325
}
319
326
}
320
327
const newWs = await WindowService . SwitchWorkspace ( this . waveWindowId , workspaceId ) ;
0 commit comments