Disable Dev Tools in production releases

`--enable-dev-tools` will bring it back.
This commit is contained in:
Fedor Indutny 2021-03-03 11:13:35 -08:00 committed by Josh Perez
parent 18fb2b806e
commit 1934120e46
3 changed files with 28 additions and 7 deletions

View File

@ -10,6 +10,7 @@ exports.createTemplate = (options, messages) => {
const {
isBeta,
devTools,
includeSetup,
openContactUs,
openForums,
@ -118,13 +119,17 @@ exports.createTemplate = (options, messages) => {
label: messages.debugLog.message,
click: showDebugLog,
},
{
type: 'separator',
},
{
role: 'toggledevtools',
label: messages.viewMenuToggleDevTools.message,
},
...(devTools
? [
{
type: 'separator',
},
{
role: 'toggledevtools',
label: messages.viewMenuToggleDevTools.message,
},
]
: []),
],
},
{

15
main.js
View File

@ -112,9 +112,16 @@ const {
getTitleBarVisibility,
TitleBarVisibility,
} = require('./ts/types/Settings');
const { Environment } = require('./ts/environment');
let appStartInitialSpellcheckSetting = true;
const defaultWebPrefs = {
devTools:
process.argv.some(arg => arg === '--enable-dev-tools') ||
config.environment !== Environment.Production,
};
async function getSpellCheckSetting() {
const json = await sql.getItemById('spell-check');
@ -313,6 +320,7 @@ async function createWindow() {
? '#ffffff' // Tests should always be rendered on a white background
: '#3a76f0',
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
@ -667,6 +675,7 @@ function showAbout() {
backgroundColor: '#3a76f0',
show: false,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
@ -721,6 +730,7 @@ function showSettingsWindow() {
show: false,
modal: true,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
@ -790,6 +800,7 @@ async function showStickerCreator() {
backgroundColor: '#3a76f0',
show: false,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
@ -844,6 +855,7 @@ async function showDebugLogWindow() {
show: false,
modal: true,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
@ -894,6 +906,7 @@ function showPermissionsPopupWindow(forCalling, forCamera) {
show: false,
modal: true,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: false,
@ -1027,6 +1040,7 @@ app.on('ready', async () => {
frame: false,
backgroundColor: '#3a76f0',
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
preload: path.join(__dirname, 'loading_preload.js'),
},
@ -1134,6 +1148,7 @@ function setupMenu(options) {
showAbout,
showSettings: showSettingsWindow,
showStickerCreator,
showDevTools: defaultWebPrefs.devTools,
openContactUs,
openJoinTheBeta,
openReleaseNotes,

View File

@ -50,6 +50,7 @@ describe('SignalMenu', () => {
};
const options = {
isBeta: false,
devTools: true,
openContactUs: null,
openForums: null,
openJoinTheBeta: null,