1
1
2
2
var ZenWorkspaces = {
3
3
async init ( ) {
4
+ let docElement = document . documentElement ;
5
+ if ( docElement . getAttribute ( "chromehidden" ) . includes ( "toolbar" )
6
+ || docElement . getAttribute ( "chromehidden" ) . includes ( "menubar" ) ) {
7
+ console . log ( "!!! ZenWorkspaces is disabled in hidden windows !!!" ) ;
8
+ return ; // We are in a hidden window, don't initialize ZenWorkspaces
9
+ }
4
10
console . log ( "Initializing ZenWorkspaces..." ) ;
5
11
await this . initializeWorkspaces ( ) ;
6
12
console . log ( "ZenWorkspaces initialized" ) ;
@@ -52,11 +58,11 @@ var ZenWorkspaces = {
52
58
let workspaces = await this . _workspaces ( ) ;
53
59
console . log ( "Workspaces loaded" , workspaces ) ;
54
60
if ( workspaces . workspaces . length === 0 ) {
55
- await this . createAndSaveWorkspace ( "Default Workspace" ) ;
61
+ await this . createAndSaveWorkspace ( "Default Workspace" , true ) ;
56
62
} else {
57
- let activeWorkspace = workspaces . workspaces . find ( workspace => workspace . used ) ;
63
+ let activeWorkspace = workspaces . workspaces . find ( workspace => workspace . default ) ;
58
64
if ( ! activeWorkspace ) {
59
- activeWorkspace = workspaces . workspaces . find ( workspace => workspace . default ) ;
65
+ activeWorkspace = workspaces . workspaces . find ( workspace => workspace . used ) ;
60
66
activeWorkspace . used = true ;
61
67
await this . saveWorkspaces ( ) ;
62
68
}
@@ -272,10 +278,10 @@ var ZenWorkspaces = {
272
278
await this . _propagateWorkspaceData ( ) ;
273
279
} ,
274
280
275
- _createWorkspaceData ( name ) {
281
+ _createWorkspaceData ( name , isDefault ) {
276
282
let window = {
277
283
uuid : gZenUIManager . generateUuidv4 ( ) ,
278
- default : false ,
284
+ default : isDefault ,
279
285
used : true ,
280
286
icon : "" ,
281
287
name : name ,
@@ -284,11 +290,11 @@ var ZenWorkspaces = {
284
290
return window ;
285
291
} ,
286
292
287
- async createAndSaveWorkspace ( name = "New Workspace" ) {
293
+ async createAndSaveWorkspace ( name = "New Workspace" , isDefault = false ) {
288
294
if ( ! this . workspaceEnabled ) {
289
295
return ;
290
296
}
291
- let workspaceData = this . _createWorkspaceData ( name ) ;
297
+ let workspaceData = this . _createWorkspaceData ( name , isDefault ) ;
292
298
await this . saveWorkspace ( workspaceData ) ;
293
299
await this . changeWorkspace ( workspaceData ) ;
294
300
} ,
0 commit comments