summaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/index.js b/src/index.js
index 6a08e5e5a..f82bb3590 100644
--- a/src/index.js
+++ b/src/index.js
@@ -8,6 +8,7 @@ import { isDevMode, isWindows } from './environment';
8import ipcApi from './electron/ipc-api'; 8import ipcApi from './electron/ipc-api';
9import Tray from './lib/Tray'; 9import Tray from './lib/Tray';
10import Settings from './electron/Settings'; 10import Settings from './electron/Settings';
11import handleDeepLink from './electron/deepLinking';
11import { appId } from './package.json'; // eslint-disable-line import/no-unresolved 12import { appId } from './package.json'; // eslint-disable-line import/no-unresolved
12import './electron/exception'; 13import './electron/exception';
13 14
@@ -26,14 +27,24 @@ if (isWindows) {
26} 27}
27 28
28// Force single window 29// Force single window
29const isSecondInstance = app.makeSingleInstance(() => { 30const isSecondInstance = app.makeSingleInstance((argv) => {
30 if (mainWindow) { 31 if (mainWindow) {
31 if (mainWindow.isMinimized()) mainWindow.restore(); 32 if (mainWindow.isMinimized()) mainWindow.restore();
32 mainWindow.focus(); 33 mainWindow.focus();
34
35 if (process.platform === 'win32') {
36 // Keep only command line / deep linked arguments
37 const url = argv.slice(1);
38
39 if (url) {
40 handleDeepLink(mainWindow, url.toString());
41 }
42 }
33 } 43 }
34}); 44});
35 45
36if (isSecondInstance) { 46if (isSecondInstance) {
47 console.log('An instance of Franz is already running. Exiting...');
37 app.exit(); 48 app.exit();
38} 49}
39 50
@@ -176,3 +187,15 @@ app.on('activate', () => {
176 mainWindow.show(); 187 mainWindow.show();
177 } 188 }
178}); 189});
190
191app.on('will-finish-launching', () => {
192 // Protocol handler for osx
193 app.on('open-url', (event, url) => {
194 event.preventDefault();
195 console.log(`open-url event: ${url}`);
196 handleDeepLink(mainWindow, url);
197 });
198});
199
200// Register App URL
201app.setAsDefaultProtocolClient('franz');