diff options
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 25 |
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'; | |||
8 | import ipcApi from './electron/ipc-api'; | 8 | import ipcApi from './electron/ipc-api'; |
9 | import Tray from './lib/Tray'; | 9 | import Tray from './lib/Tray'; |
10 | import Settings from './electron/Settings'; | 10 | import Settings from './electron/Settings'; |
11 | import handleDeepLink from './electron/deepLinking'; | ||
11 | import { appId } from './package.json'; // eslint-disable-line import/no-unresolved | 12 | import { appId } from './package.json'; // eslint-disable-line import/no-unresolved |
12 | import './electron/exception'; | 13 | import './electron/exception'; |
13 | 14 | ||
@@ -26,14 +27,24 @@ if (isWindows) { | |||
26 | } | 27 | } |
27 | 28 | ||
28 | // Force single window | 29 | // Force single window |
29 | const isSecondInstance = app.makeSingleInstance(() => { | 30 | const 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 | ||
36 | if (isSecondInstance) { | 46 | if (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 | |||
191 | app.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 | ||
201 | app.setAsDefaultProtocolClient('franz'); | ||