aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js61
1 files changed, 30 insertions, 31 deletions
diff --git a/src/index.js b/src/index.js
index 7f1f77b4e..08d9a3a45 100644
--- a/src/index.js
+++ b/src/index.js
@@ -78,14 +78,18 @@ if (isWindows) {
78const settings = new Settings('app', DEFAULT_APP_SETTINGS); 78const settings = new Settings('app', DEFAULT_APP_SETTINGS);
79const proxySettings = new Settings('proxy'); 79const proxySettings = new Settings('proxy');
80 80
81const retrieveSettingValue = (key, defaultValue = true) => ifUndefinedBoolean(settings.get(key), defaultValue); 81const retrieveSettingValue = (key, defaultValue = true) =>
82 ifUndefinedBoolean(settings.get(key), defaultValue);
82 83
83if (retrieveSettingValue('sentry')) { 84if (retrieveSettingValue('sentry')) {
84 // eslint-disable-next-line global-require 85 // eslint-disable-next-line global-require
85 require('./sentry'); 86 require('./sentry');
86} 87}
87 88
88const liftSingleInstanceLock = retrieveSettingValue('liftSingleInstanceLock', false); 89const liftSingleInstanceLock = retrieveSettingValue(
90 'liftSingleInstanceLock',
91 false,
92);
89 93
90// Force single window 94// Force single window
91const gotTheLock = liftSingleInstanceLock 95const gotTheLock = liftSingleInstanceLock
@@ -190,11 +194,11 @@ const createWindow = () => {
190 minWidth: 600, 194 minWidth: 600,
191 minHeight: 500, 195 minHeight: 500,
192 show: false, 196 show: false,
193 titleBarStyle: isMac ? 'hidden' : '', 197 titleBarStyle: isMac ? 'hidden' : 'default',
194 frame: isLinux, 198 frame: isLinux,
195 spellcheck: retrieveSettingValue('enableSpellchecking'),
196 backgroundColor, 199 backgroundColor,
197 webPreferences: { 200 webPreferences: {
201 spellcheck: retrieveSettingValue('enableSpellchecking'),
198 nodeIntegration: true, 202 nodeIntegration: true,
199 contextIsolation: false, 203 contextIsolation: false,
200 webviewTag: true, 204 webviewTag: true,
@@ -268,10 +272,7 @@ const createWindow = () => {
268 // Dereference the window object, usually you would store windows 272 // Dereference the window object, usually you would store windows
269 // in an array if your app supports multi windows, this is the time 273 // in an array if your app supports multi windows, this is the time
270 // when you should delete the corresponding element. 274 // when you should delete the corresponding element.
271 if ( 275 if (!willQuitApp && retrieveSettingValue('runInBackground')) {
272 !willQuitApp &&
273 retrieveSettingValue('runInBackground')
274 ) {
275 e.preventDefault(); 276 e.preventDefault();
276 if (isWindows) { 277 if (isWindows) {
277 debug('Window: minimize'); 278 debug('Window: minimize');
@@ -471,7 +472,9 @@ ipcMain.on('open-browser-window', (e, { url, serviceId }) => {
471ipcMain.on( 472ipcMain.on(
472 'modifyRequestHeaders', 473 'modifyRequestHeaders',
473 (e, { modifiedRequestHeaders, serviceId }) => { 474 (e, { modifiedRequestHeaders, serviceId }) => {
474 debug(`Received modifyRequestHeaders ${modifiedRequestHeaders} for serviceId ${serviceId}`); 475 debug(
476 `Received modifyRequestHeaders ${modifiedRequestHeaders} for serviceId ${serviceId}`,
477 );
475 modifiedRequestHeaders.forEach(headerFilterSet => { 478 modifiedRequestHeaders.forEach(headerFilterSet => {
476 const { headers, requestFilters } = headerFilterSet; 479 const { headers, requestFilters } = headerFilterSet;
477 session 480 session
@@ -489,23 +492,22 @@ ipcMain.on(
489 }, 492 },
490); 493);
491 494
492ipcMain.on( 495ipcMain.on('knownCertificateHosts', (e, { knownHosts, serviceId }) => {
493 'knownCertificateHosts', 496 debug(
494 (e, { knownHosts, serviceId }) => { 497 `Received knownCertificateHosts ${knownHosts} for serviceId ${serviceId}`,
495 debug(`Received knownCertificateHosts ${knownHosts} for serviceId ${serviceId}`); 498 );
496 session 499 session
497 .fromPartition(`persist:service-${serviceId}`) 500 .fromPartition(`persist:service-${serviceId}`)
498 .setCertificateVerifyProc((request, callback) => { 501 .setCertificateVerifyProc((request, callback) => {
499 // To know more about these callbacks: https://www.electronjs.org/docs/api/session#sessetcertificateverifyprocproc 502 // To know more about these callbacks: https://www.electronjs.org/docs/api/session#sessetcertificateverifyprocproc
500 const { hostname } = request; 503 const { hostname } = request;
501 if (knownHosts.find(item => item.includes(hostname)).length > 0) { 504 if (knownHosts.find(item => item.includes(hostname)).length > 0) {
502 callback(0); 505 callback(0);
503 } else { 506 } else {
504 callback(-2); 507 callback(-2);
505 } 508 }
506 }); 509 });
507 }, 510});
508);
509 511
510ipcMain.on('feature-basic-auth-cancel', () => { 512ipcMain.on('feature-basic-auth-cancel', () => {
511 debug('Cancel basic auth'); 513 debug('Cancel basic auth');
@@ -560,7 +562,7 @@ app.on('window-all-closed', () => {
560 } 562 }
561}); 563});
562 564
563app.on('before-quit', (event) => { 565app.on('before-quit', event => {
564 const yesButtonIndex = 0; 566 const yesButtonIndex = 0;
565 let selection = yesButtonIndex; 567 let selection = yesButtonIndex;
566 if (retrieveSettingValue('confirmOnQuit')) { 568 if (retrieveSettingValue('confirmOnQuit')) {
@@ -568,10 +570,7 @@ app.on('before-quit', (event) => {
568 type: 'question', 570 type: 'question',
569 message: 'Quit', 571 message: 'Quit',
570 detail: 'Do you really want to quit Ferdi?', 572 detail: 'Do you really want to quit Ferdi?',
571 buttons: [ 573 buttons: ['Yes', 'No'],
572 'Yes',
573 'No',
574 ],
575 }); 574 });
576 } 575 }
577 if (selection === yesButtonIndex) { 576 if (selection === yesButtonIndex) {