7
7
const AppConfig = require ( './constants/appConfig' )
8
8
const AppActions = require ( '../js/actions/appActions' )
9
9
const messages = require ( '../js/constants/messages' )
10
+ const Immutable = require ( 'immutable' )
10
11
11
12
const httpsEverywhere = AppConfig . resourceNames . HTTPS_EVERYWHERE
12
13
const adblock = AppConfig . resourceNames . ADBLOCK
@@ -30,6 +31,12 @@ if (process.type === 'browser') {
30
31
app = electron . remote . app
31
32
}
32
33
34
+ const ensureAtLeastOneWindow = ( frameOpts ) => {
35
+ if ( electron . BrowserWindow . getAllWindows ( ) . length === 0 ) {
36
+ AppActions . newWindow ( frameOpts )
37
+ }
38
+ }
39
+
33
40
/**
34
41
* Sends a message to the web contents of the focused window.
35
42
* @param {Object } focusedWindow the focusedWindow if any
@@ -66,6 +73,7 @@ module.exports.newPrivateTabMenuItem = {
66
73
label : 'New Private Tab' ,
67
74
accelerator : 'CmdOrCtrl+Alt+T' ,
68
75
click : function ( item , focusedWindow ) {
76
+ ensureAtLeastOneWindow ( Immutable . fromJS ( { isPrivate : true } ) )
69
77
module . exports . sendToFocusedWindow ( focusedWindow , [ messages . SHORTCUT_NEW_FRAME , undefined , { isPrivate : true } ] )
70
78
}
71
79
}
@@ -74,6 +82,7 @@ module.exports.newPartitionedTabMenuItem = {
74
82
label : 'New Session Tab' ,
75
83
accelerator : 'CmdOrCtrl+Alt+S' ,
76
84
click : function ( item , focusedWindow ) {
85
+ ensureAtLeastOneWindow ( Immutable . fromJS ( { isPartitioned : true } ) )
77
86
module . exports . sendToFocusedWindow ( focusedWindow , [ messages . SHORTCUT_NEW_FRAME , undefined , { isPartitioned : true } ] )
78
87
}
79
88
}
@@ -115,9 +124,7 @@ module.exports.findOnPageMenuItem = {
115
124
module . exports . checkForUpdateMenuItem = {
116
125
label : 'Check for updates...' ,
117
126
click : function ( item , focusedWindow ) {
118
- if ( electron . BrowserWindow . getAllWindows ( ) . length === 0 ) {
119
- AppActions . newWindow ( )
120
- }
127
+ ensureAtLeastOneWindow ( )
121
128
process . emit ( messages . CHECK_FOR_UPDATE )
122
129
}
123
130
}
0 commit comments