aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
authorLibravatar Amine El Mouafik <412895+kytwb@users.noreply.github.com>2021-02-08 10:34:45 +0100
committerLibravatar GitHub <noreply@github.com>2021-02-08 10:34:45 +0100
commit035002ceedf78d5ec73eabc0df7f06139939b967 (patch)
tree1c0d1e9531bae05fb65d70b9ea25baf404b74fe1 /src/index.js
parentdocs: add k0staa as a contributor (#1193) (diff)
downloadferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.tar.gz
ferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.tar.zst
ferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.zip
Synchronize with Franz 5.6.0 (#1033)
Co-authored-by: FranzBot <i18n@meetfranz.com> Co-authored-by: vantezzen <hello@vantezzen.io> Co-authored-by: Makazzz <makazzzpro@live.ca> Co-authored-by: Stefan Malzner <stefan@adlk.io> Co-authored-by: Amine Mouafik <amine@mouafik.fr>
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js31
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';
9import fs from 'fs-extra'; 9import fs from 'fs-extra';
10import path from 'path'; 10import path from 'path';
11import windowStateKeeper from 'electron-window-state'; 11import windowStateKeeper from 'electron-window-state';
12import { enforceMacOSAppLocation } from 'electron-util';
12 13
13// Set app directory before loading user modules 14// Set app directory before loading user modules
14if (process.env.FERDI_APPDATA_DIR != null) { 15if (process.env.FERDI_APPDATA_DIR != null) {
@@ -39,7 +40,7 @@ import DBus from './lib/DBus';
39import Settings from './electron/Settings'; 40import Settings from './electron/Settings';
40import handleDeepLink from './electron/deepLinking'; 41import handleDeepLink from './electron/deepLinking';
41import { isPositionValid } from './electron/windowUtils'; 42import { isPositionValid } from './electron/windowUtils';
42// import askFormacOSPermissions from './electron/macOSPermissions'; 43import askFormacOSPermissions from './electron/macOSPermissions';
43import { appId } from './package.json'; // eslint-disable-line import/no-unresolved 44import { appId } from './package.json'; // eslint-disable-line import/no-unresolved
44import './electron/exception'; 45import './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
65debug('Set userAgent to ', userAgent());
66app.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
65debug('Set userAgent to ', userAgent()); 69debug('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.
374app.on('ready', () => { 378app.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
492app.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
485app.on('will-finish-launching', () => { 498app.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) => {