diff options
author | 2017-12-05 16:04:27 +0100 | |
---|---|---|
committer | 2017-12-05 16:04:27 +0100 | |
commit | 49cdd35696dcbe2a90c63dccc2d88db46e2aa8a9 (patch) | |
tree | c9e20ff61d332c759522d2227d90cd56fabc8008 /src | |
parent | Merge pull request #400 from meetfranz/feature/delete-account (diff) | |
download | ferdium-app-49cdd35696dcbe2a90c63dccc2d88db46e2aa8a9.tar.gz ferdium-app-49cdd35696dcbe2a90c63dccc2d88db46e2aa8a9.tar.zst ferdium-app-49cdd35696dcbe2a90c63dccc2d88db46e2aa8a9.zip |
WIP: add deep linking
Diffstat (limited to 'src')
-rw-r--r-- | src/electron/deepLinking.js | 5 | ||||
-rw-r--r-- | src/index.js | 26 | ||||
-rw-r--r-- | src/stores/AppStore.js | 5 |
3 files changed, 34 insertions, 2 deletions
diff --git a/src/electron/deepLinking.js b/src/electron/deepLinking.js new file mode 100644 index 000000000..819fdd095 --- /dev/null +++ b/src/electron/deepLinking.js | |||
@@ -0,0 +1,5 @@ | |||
1 | export default function handleDeepLink(window, url) { | ||
2 | console.log(url); | ||
3 | |||
4 | window.webContents.send('navigateFromDeepLink', { url }); | ||
5 | } | ||
diff --git a/src/index.js b/src/index.js index 6a08e5e5a..4b6241f13 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,10 +27,18 @@ 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 | console.log(url); | ||
40 | handleDeepLink(mainWindow, url); | ||
41 | } | ||
33 | } | 42 | } |
34 | }); | 43 | }); |
35 | 44 | ||
@@ -70,7 +79,8 @@ const createWindow = () => { | |||
70 | const trayIcon = new Tray(); | 79 | const trayIcon = new Tray(); |
71 | 80 | ||
72 | // Initialize ipcApi | 81 | // Initialize ipcApi |
73 | ipcApi({ mainWindow, settings, trayIcon }); | 82 | const franzIpcApi = ipcApi({ mainWindow, settings, trayIcon }); |
83 | console.log(franzIpcApi); | ||
74 | 84 | ||
75 | // Manage Window State | 85 | // Manage Window State |
76 | mainWindowState.manage(mainWindow); | 86 | mainWindowState.manage(mainWindow); |
@@ -176,3 +186,15 @@ app.on('activate', () => { | |||
176 | mainWindow.show(); | 186 | mainWindow.show(); |
177 | } | 187 | } |
178 | }); | 188 | }); |
189 | |||
190 | app.on('will-finish-launching', () => { | ||
191 | // Protocol handler for osx | ||
192 | app.on('open-url', (event, url) => { | ||
193 | event.preventDefault(); | ||
194 | console.log(`open-url event: ${url}`); | ||
195 | handleDeepLink(mainWindow, url); | ||
196 | }); | ||
197 | }); | ||
198 | |||
199 | // Register App URL | ||
200 | app.setAsDefaultProtocolClient('franz'); | ||
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 17ec832cf..557c9f7f2 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -116,6 +116,11 @@ export default class AppStore extends Store { | |||
116 | } | 116 | } |
117 | }); | 117 | }); |
118 | 118 | ||
119 | // Handle deep linking (franz://) | ||
120 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { | ||
121 | console.log(event, data); | ||
122 | }); | ||
123 | |||
119 | // Check system idle time every minute | 124 | // Check system idle time every minute |
120 | setInterval(() => { | 125 | setInterval(() => { |
121 | this.idleTime = idleTimer.getIdleTime(); | 126 | this.idleTime = idleTimer.getIdleTime(); |