diff options
-rw-r--r-- | electron-builder.yml | 4 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/electron/deepLinking.js | 5 | ||||
-rw-r--r-- | src/index.js | 30 | ||||
-rw-r--r-- | src/stores/AppStore.js | 8 |
5 files changed, 46 insertions, 2 deletions
diff --git a/electron-builder.yml b/electron-builder.yml index 03e59e462..96bd63cc2 100644 --- a/electron-builder.yml +++ b/electron-builder.yml | |||
@@ -34,3 +34,7 @@ linux: | |||
34 | nsis: | 34 | nsis: |
35 | perMachine: false | 35 | perMachine: false |
36 | oneClick: true | 36 | oneClick: true |
37 | |||
38 | protocols: | ||
39 | name: Franz | ||
40 | schemes: [franz] | ||
diff --git a/package.json b/package.json index 8a5eee7b2..9c111d336 100644 --- a/package.json +++ b/package.json | |||
@@ -6,6 +6,7 @@ | |||
6 | "description": "Messaging app for WhatsApp, Slack, Telegram, HipChat, Hangouts and many many more.", | 6 | "description": "Messaging app for WhatsApp, Slack, Telegram, HipChat, Hangouts and many many more.", |
7 | "copyright": "adlk x franz - Stefan Malzner", | 7 | "copyright": "adlk x franz - Stefan Malzner", |
8 | "main": "index.js", | 8 | "main": "index.js", |
9 | "homepage": "https://meetfranz.com", | ||
9 | "repository": "https://github.com/meetfranz/franz.git", | 10 | "repository": "https://github.com/meetfranz/franz.git", |
10 | "private": true, | 11 | "private": true, |
11 | "scripts": { | 12 | "scripts": { |
diff --git a/src/electron/deepLinking.js b/src/electron/deepLinking.js new file mode 100644 index 000000000..16e68b914 --- /dev/null +++ b/src/electron/deepLinking.js | |||
@@ -0,0 +1,5 @@ | |||
1 | export default function handleDeepLink(window, rawUrl) { | ||
2 | const url = rawUrl.replace('franz://', ''); | ||
3 | |||
4 | window.webContents.send('navigateFromDeepLink', { url }); | ||
5 | } | ||
diff --git a/src/index.js b/src/index.js index 6a08e5e5a..4253b681f 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,20 @@ 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 | console.log(url.toString()); | ||
41 | handleDeepLink(mainWindow, url.toString()); | ||
42 | } | ||
43 | } | ||
33 | } | 44 | } |
34 | }); | 45 | }); |
35 | 46 | ||
@@ -70,7 +81,8 @@ const createWindow = () => { | |||
70 | const trayIcon = new Tray(); | 81 | const trayIcon = new Tray(); |
71 | 82 | ||
72 | // Initialize ipcApi | 83 | // Initialize ipcApi |
73 | ipcApi({ mainWindow, settings, trayIcon }); | 84 | const franzIpcApi = ipcApi({ mainWindow, settings, trayIcon }); |
85 | console.log(franzIpcApi); | ||
74 | 86 | ||
75 | // Manage Window State | 87 | // Manage Window State |
76 | mainWindowState.manage(mainWindow); | 88 | mainWindowState.manage(mainWindow); |
@@ -137,6 +149,8 @@ const createWindow = () => { | |||
137 | 149 | ||
138 | mainWindow.on('show', () => { | 150 | mainWindow.on('show', () => { |
139 | mainWindow.setSkipTaskbar(false); | 151 | mainWindow.setSkipTaskbar(false); |
152 | |||
153 | handleDeepLink(mainWindow, 'franz://settings/services/add/msteams'); | ||
140 | }); | 154 | }); |
141 | 155 | ||
142 | app.mainWindow = mainWindow; | 156 | app.mainWindow = mainWindow; |
@@ -176,3 +190,15 @@ app.on('activate', () => { | |||
176 | mainWindow.show(); | 190 | mainWindow.show(); |
177 | } | 191 | } |
178 | }); | 192 | }); |
193 | |||
194 | app.on('will-finish-launching', () => { | ||
195 | // Protocol handler for osx | ||
196 | app.on('open-url', (event, url) => { | ||
197 | event.preventDefault(); | ||
198 | console.log(`open-url event: ${url}`); | ||
199 | handleDeepLink(mainWindow, url); | ||
200 | }); | ||
201 | }); | ||
202 | |||
203 | // Register App URL | ||
204 | app.setAsDefaultProtocolClient('franz'); | ||
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 17ec832cf..3e6d4d288 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -116,6 +116,14 @@ export default class AppStore extends Store { | |||
116 | } | 116 | } |
117 | }); | 117 | }); |
118 | 118 | ||
119 | // Handle deep linking (franz://) | ||
120 | ipcRenderer.on('navigateFromDeepLink', (event, data) => { | ||
121 | const { url } = data; | ||
122 | if (!url) return; | ||
123 | |||
124 | this.stores.router.push(data.url); | ||
125 | }); | ||
126 | |||
119 | // Check system idle time every minute | 127 | // Check system idle time every minute |
120 | setInterval(() => { | 128 | setInterval(() => { |
121 | this.idleTime = idleTimer.getIdleTime(); | 129 | this.idleTime = idleTimer.getIdleTime(); |