Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit 6ae3e36

Browse files
committed
Allow new session/private tabs when no windows
Fix #914 Auditors: @diracdeltas
1 parent 4d5332e commit 6ae3e36

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

js/commonMenu.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
const AppConfig = require('./constants/appConfig')
88
const AppActions = require('../js/actions/appActions')
99
const messages = require('../js/constants/messages')
10+
const Immutable = require('immutable')
1011

1112
const httpsEverywhere = AppConfig.resourceNames.HTTPS_EVERYWHERE
1213
const adblock = AppConfig.resourceNames.ADBLOCK
@@ -30,6 +31,12 @@ if (process.type === 'browser') {
3031
app = electron.remote.app
3132
}
3233

34+
const ensureAtLeastOneWindow = (frameOpts) => {
35+
if (electron.BrowserWindow.getAllWindows().length === 0) {
36+
AppActions.newWindow(frameOpts)
37+
}
38+
}
39+
3340
/**
3441
* Sends a message to the web contents of the focused window.
3542
* @param {Object} focusedWindow the focusedWindow if any
@@ -66,6 +73,7 @@ module.exports.newPrivateTabMenuItem = {
6673
label: 'New Private Tab',
6774
accelerator: 'CmdOrCtrl+Alt+T',
6875
click: function (item, focusedWindow) {
76+
ensureAtLeastOneWindow(Immutable.fromJS({ isPrivate: true }))
6977
module.exports.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_NEW_FRAME, undefined, { isPrivate: true }])
7078
}
7179
}
@@ -74,6 +82,7 @@ module.exports.newPartitionedTabMenuItem = {
7482
label: 'New Session Tab',
7583
accelerator: 'CmdOrCtrl+Alt+S',
7684
click: function (item, focusedWindow) {
85+
ensureAtLeastOneWindow(Immutable.fromJS({ isPartitioned: true }))
7786
module.exports.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_NEW_FRAME, undefined, { isPartitioned: true }])
7887
}
7988
}
@@ -115,9 +124,7 @@ module.exports.findOnPageMenuItem = {
115124
module.exports.checkForUpdateMenuItem = {
116125
label: 'Check for updates...',
117126
click: function (item, focusedWindow) {
118-
if (electron.BrowserWindow.getAllWindows().length === 0) {
119-
AppActions.newWindow()
120-
}
127+
ensureAtLeastOneWindow()
121128
process.emit(messages.CHECK_FOR_UPDATE)
122129
}
123130
}

0 commit comments

Comments
 (0)