From 36822a25fa1f978c4dc06743600cc51bf774d4ea Mon Sep 17 00:00:00 2001 From: André Oliveira Date: Thu, 28 Jul 2022 10:11:04 +0100 Subject: fix: handleDeepLink generalization --- src/electron/deepLinking.ts | 11 ++++++++++- src/index.ts | 13 ++----------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/electron/deepLinking.ts b/src/electron/deepLinking.ts index 36de1b143..104aa2d83 100644 --- a/src/electron/deepLinking.ts +++ b/src/electron/deepLinking.ts @@ -4,9 +4,18 @@ export default function handleDeepLink( window: BrowserWindow, rawUrl: string, ): void { + if (!rawUrl) { + return; + } + const url = rawUrl.replace('ferdium://', ''); - if (!url) return; + // The next line is a workaround after this 71c5237 [chore: Mobx & React-Router upgrade (#406)]. + // For some reason, the app won't start until because it's trying to route to './build'. + // TODO: Check what is wrong with DeepLinking - it is broken for some reason. This is causing several troubles. + const workaroundDeepLink = ['./build', '--allow-file-access-from-files']; + + if (!url || workaroundDeepLink.includes(url)) return; window.webContents.send('navigateFromDeepLink', { url }); } diff --git a/src/index.ts b/src/index.ts index 9a1163067..05e222a25 100644 --- a/src/index.ts +++ b/src/index.ts @@ -119,9 +119,7 @@ if (!gotTheLock) { onDidLoad((window: BrowserWindow) => { // Keep only command line / deep linked arguments const url = argv.slice(1); - if (url) { - handleDeepLink(window, url.toString()); - } + handleDeepLink(window, url.toString()); if (argv.includes('--reset-window')) { // Needs to be delayed to not interfere with mainWindow.restore(); @@ -270,14 +268,7 @@ const createWindow = () => { if (isWindows) { onDidLoad((window: BrowserWindow) => { const url = process.argv.slice(1); - if ( - url && - // The next line is a workaround after this 71c5237 [chore: Mobx & React-Router upgrade (#406)]. - // For some reason, the app won't start until because it's trying to route to './build'. - url.toString() !== './build' - ) { - handleDeepLink(window, url.toString()); - } + handleDeepLink(window, url.toString()); }); } -- cgit v1.2.3-54-g00ecf