summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2023-09-04 00:02:22 +0100
committerLibravatar GitHub <noreply@github.com>2023-09-04 00:02:22 +0100
commit970738c953865b7346f5f85c576be2af2cdd7f2c (patch)
tree9a05d25a6d0128b8197f0f38a2a013d1d842cebc /src
parentUpgrade npm modules (#1343) (diff)
downloadferdium-app-970738c953865b7346f5f85c576be2af2cdd7f2c.tar.gz
ferdium-app-970738c953865b7346f5f85c576be2af2cdd7f2c.tar.zst
ferdium-app-970738c953865b7346f5f85c576be2af2cdd7f2c.zip
feat: add deeplink to service (#1344)
add deeplink to service
Diffstat (limited to 'src')
-rw-r--r--src/electron/deepLinking.ts3
-rw-r--r--src/environment-remote.ts2
-rw-r--r--src/index.ts2
-rw-r--r--src/stores/AppStore.ts14
4 files changed, 19 insertions, 2 deletions
diff --git a/src/electron/deepLinking.ts b/src/electron/deepLinking.ts
index 104aa2d83..14cb8e5b1 100644
--- a/src/electron/deepLinking.ts
+++ b/src/electron/deepLinking.ts
@@ -1,4 +1,5 @@
1import { BrowserWindow } from 'electron'; 1import { BrowserWindow } from 'electron';
2import { protocolClient } from '../environment-remote';
2 3
3export default function handleDeepLink( 4export default function handleDeepLink(
4 window: BrowserWindow, 5 window: BrowserWindow,
@@ -8,7 +9,7 @@ export default function handleDeepLink(
8 return; 9 return;
9 } 10 }
10 11
11 const url = rawUrl.replace('ferdium://', ''); 12 const url = rawUrl.replace(`${protocolClient}://`, '');
12 13
13 // The next line is a workaround after this 71c5237 [chore: Mobx & React-Router upgrade (#406)]. 14 // The next line is a workaround after this 71c5237 [chore: Mobx & React-Router upgrade (#406)].
14 // For some reason, the app won't start until because it's trying to route to './build'. 15 // For some reason, the app won't start until because it's trying to route to './build'.
diff --git a/src/environment-remote.ts b/src/environment-remote.ts
index 691e19ef4..da1477346 100644
--- a/src/environment-remote.ts
+++ b/src/environment-remote.ts
@@ -79,3 +79,5 @@ export const API_VERSION: string = 'v1';
79export const WS_API: string = wsApi; 79export const WS_API: string = wsApi;
80export const WEBSITE: string = web; 80export const WEBSITE: string = web;
81export const TODOS_FRONTEND: string = todos; 81export const TODOS_FRONTEND: string = todos;
82// For deeplink protocol: 'ferdium' or 'ferdium-dev' if we want '{DEEPLINK_PROTOCOL_CLIENT}://'
83export const protocolClient = isDevMode ? 'ferdium-dev' : 'ferdium';
diff --git a/src/index.ts b/src/index.ts
index 5accc4570..c765bac73 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -29,6 +29,7 @@ import {
29 isDevMode, 29 isDevMode,
30 userDataRecipesPath, 30 userDataRecipesPath,
31 userDataPath, 31 userDataPath,
32 protocolClient,
32} from './environment-remote'; 33} from './environment-remote';
33import { ifUndefined } from './jsUtils'; 34import { ifUndefined } from './jsUtils';
34 35
@@ -469,7 +470,6 @@ app.on('ready', () => {
469 enforceMacOSAppLocation(); 470 enforceMacOSAppLocation();
470 471
471 // Register App URL 472 // Register App URL
472 const protocolClient = isDevMode ? 'ferdium-dev' : 'ferdium';
473 if (!app.isDefaultProtocolClient(protocolClient, process.execPath)) { 473 if (!app.isDefaultProtocolClient(protocolClient, process.execPath)) {
474 app.setAsDefaultProtocolClient(protocolClient, process.execPath); 474 app.setAsDefaultProtocolClient(protocolClient, process.execPath);
475 } 475 }
diff --git a/src/stores/AppStore.ts b/src/stores/AppStore.ts
index 1c1336819..df8c17c01 100644
--- a/src/stores/AppStore.ts
+++ b/src/stores/AppStore.ts
@@ -263,6 +263,20 @@ export default class AppStore extends TypedStore {
263 url = url.replace(/\/$/, ''); 263 url = url.replace(/\/$/, '');
264 url = url.replace(/\s?--(updated)/, ''); 264 url = url.replace(/\s?--(updated)/, '');
265 265
266 if (url.startsWith('service/')) {
267 const pattern = /service\/([^/]+)/;
268 // Use the exec method to extract the id from the URL
269 const match = pattern.exec(url);
270
271 if (match) {
272 const id = match[1]; // The id is captured in the first capture group
273 this.actions.service.setActive({
274 serviceId: id,
275 });
276 }
277 return;
278 }
279
266 this.stores.router.push(url); 280 this.stores.router.push(url);
267 }); 281 });
268 282