aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-12-05 16:04:27 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-12-05 16:04:27 +0100
commit49cdd35696dcbe2a90c63dccc2d88db46e2aa8a9 (patch)
treec9e20ff61d332c759522d2227d90cd56fabc8008
parentMerge pull request #400 from meetfranz/feature/delete-account (diff)
downloadferdium-app-49cdd35696dcbe2a90c63dccc2d88db46e2aa8a9.tar.gz
ferdium-app-49cdd35696dcbe2a90c63dccc2d88db46e2aa8a9.tar.zst
ferdium-app-49cdd35696dcbe2a90c63dccc2d88db46e2aa8a9.zip
WIP: add deep linking
-rw-r--r--electron-builder.yml4
-rw-r--r--package.json1
-rw-r--r--src/electron/deepLinking.js5
-rw-r--r--src/index.js26
-rw-r--r--src/stores/AppStore.js5
5 files changed, 39 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:
34nsis: 34nsis:
35 perMachine: false 35 perMachine: false
36 oneClick: true 36 oneClick: true
37
38protocols:
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..819fdd095
--- /dev/null
+++ b/src/electron/deepLinking.js
@@ -0,0 +1,5 @@
1export 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';
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,10 +27,18 @@ 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 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
190app.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
200app.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();