From 5361ef5aba076dc37d2886cf1e889be5e9d8c3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Esp=C3=ADn?= Date: Thu, 2 Nov 2023 18:27:02 +0100 Subject: [PATCH] fix: parse deeplink url at start (#7610) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Parse deeplink url at start * clean up * fix * simplify * clean up * :skull: --------- Co-authored-by: Begoña Álvarez de la Cruz --- packages/desktop/electron/main.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/desktop/electron/main.js b/packages/desktop/electron/main.js index 74ccfd7d135..5ff2993a8ec 100644 --- a/packages/desktop/electron/main.js +++ b/packages/desktop/electron/main.js @@ -455,10 +455,12 @@ ipcMain.handle('get-machine-id', (_e) => getMachineId()) ipcMain.handle('update-app-settings', (_e, settings) => updateSettings(settings)) ipcMain.handle('update-theme', (_e, theme) => (nativeTheme.themeSource = theme)) +const argWithAppProtocol = (arg) => arg.startsWith(`${process.env.APP_PROTOCOL}://`) + /** * Define deep link state */ -let deepLinkUrl = null +let deepLinkUrl = process.argv.find(argWithAppProtocol) /** * Create a single instance only @@ -472,7 +474,7 @@ if (!isFirstInstance) { app.on('second-instance', (_e, args) => { if (windows.main) { if (args.length > 1) { - const params = args.find((arg) => arg.startsWith(`${process.env.APP_PROTOCOL}://`)) + const params = args.find(argWithAppProtocol) if (params) { windows.main.webContents.send('deep-link-params', params)