diff options
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/index.js b/src/index.js index 28bbe19c1..b297d66d8 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -9,6 +9,7 @@ import isDevMode from 'electron-is-dev'; | |||
9 | import fs from 'fs-extra'; | 9 | import fs from 'fs-extra'; |
10 | import path from 'path'; | 10 | import path from 'path'; |
11 | import windowStateKeeper from 'electron-window-state'; | 11 | import windowStateKeeper from 'electron-window-state'; |
12 | import { enforceMacOSAppLocation } from 'electron-util'; | ||
12 | 13 | ||
13 | // Set app directory before loading user modules | 14 | // Set app directory before loading user modules |
14 | if (process.env.FERDI_APPDATA_DIR != null) { | 15 | if (process.env.FERDI_APPDATA_DIR != null) { |
@@ -39,7 +40,7 @@ import DBus from './lib/DBus'; | |||
39 | import Settings from './electron/Settings'; | 40 | import Settings from './electron/Settings'; |
40 | import handleDeepLink from './electron/deepLinking'; | 41 | import handleDeepLink from './electron/deepLinking'; |
41 | import { isPositionValid } from './electron/windowUtils'; | 42 | import { isPositionValid } from './electron/windowUtils'; |
42 | // import askFormacOSPermissions from './electron/macOSPermissions'; | 43 | import askFormacOSPermissions from './electron/macOSPermissions'; |
43 | import { appId } from './package.json'; // eslint-disable-line import/no-unresolved | 44 | import { appId } from './package.json'; // eslint-disable-line import/no-unresolved |
44 | import './electron/exception'; | 45 | import './electron/exception'; |
45 | 46 | ||
@@ -60,6 +61,9 @@ if (isWindows) { | |||
60 | app.allowRendererProcessReuse = false; | 61 | app.allowRendererProcessReuse = false; |
61 | } | 62 | } |
62 | 63 | ||
64 | // Globally set useragent to fix user agent override in service workers | ||
65 | debug('Set userAgent to ', userAgent()); | ||
66 | app.userAgentFallback = userAgent(); | ||
63 | 67 | ||
64 | // Globally set useragent to fix user agent override in service workers | 68 | // Globally set useragent to fix user agent override in service workers |
65 | debug('Set userAgent to ', userAgent()); | 69 | debug('Set userAgent to ', userAgent()); |
@@ -212,10 +216,11 @@ const createWindow = () => { | |||
212 | mainWindow.webContents.on('did-finish-load', () => { | 216 | mainWindow.webContents.on('did-finish-load', () => { |
213 | const fns = onDidLoadFns; | 217 | const fns = onDidLoadFns; |
214 | onDidLoadFns = null; | 218 | onDidLoadFns = null; |
215 | if (fns) { | 219 | |
216 | for (const fn of fns) { // eslint-disable-line no-unused-vars | 220 | if (!fns) return; |
217 | fn(mainWindow); | 221 | |
218 | } | 222 | for (const fn of fns) { |
223 | fn(mainWindow); | ||
219 | } | 224 | } |
220 | }); | 225 | }); |
221 | 226 | ||
@@ -322,10 +327,9 @@ const createWindow = () => { | |||
322 | } | 327 | } |
323 | }); | 328 | }); |
324 | 329 | ||
325 | // Asking for permissions like this currently crashes Ferdi | 330 | if (isMac) { |
326 | // if (isMac) { | 331 | askFormacOSPermissions(); |
327 | // askFormacOSPermissions(); | 332 | } |
328 | // } | ||
329 | 333 | ||
330 | mainWindow.on('show', () => { | 334 | mainWindow.on('show', () => { |
331 | debug('Skip taskbar: true'); | 335 | debug('Skip taskbar: true'); |
@@ -372,6 +376,9 @@ app.commandLine.appendSwitch('disable-features', 'HardwareMediaKeyHandling,Media | |||
372 | // initialization and is ready to create browser windows. | 376 | // initialization and is ready to create browser windows. |
373 | // Some APIs can only be used after this event occurs. | 377 | // Some APIs can only be used after this event occurs. |
374 | app.on('ready', () => { | 378 | app.on('ready', () => { |
379 | // force app to live in /Applications | ||
380 | enforceMacOSAppLocation(); | ||
381 | |||
375 | // Register App URL | 382 | // Register App URL |
376 | app.setAsDefaultProtocolClient('ferdi'); | 383 | app.setAsDefaultProtocolClient('ferdi'); |
377 | 384 | ||
@@ -482,6 +489,12 @@ app.on('activate', () => { | |||
482 | } | 489 | } |
483 | }); | 490 | }); |
484 | 491 | ||
492 | app.on('web-contents-created', (createdEvent, contents) => { | ||
493 | contents.on('new-window', (event, url, frameNme, disposition) => { | ||
494 | if (disposition === 'foreground-tab') event.preventDefault(); | ||
495 | }); | ||
496 | }); | ||
497 | |||
485 | app.on('will-finish-launching', () => { | 498 | app.on('will-finish-launching', () => { |
486 | // Protocol handler for macOS | 499 | // Protocol handler for macOS |
487 | app.on('open-url', (event, url) => { | 500 | app.on('open-url', (event, url) => { |