From 3bffc9f90f9b8368341348e606f026a2fbb61f75 Mon Sep 17 00:00:00 2001 From: Devin Binnie Date: Mon, 11 Nov 2024 11:04:53 -0500 Subject: [PATCH 1/2] Fixed issues with loading the app from cold when deep linking --- src/main/app/utils.ts | 10 +++++++--- src/main/views/viewManager.ts | 8 +++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/app/utils.ts b/src/main/app/utils.ts index f08c829a55f..4ce4d5eef19 100644 --- a/src/main/app/utils.ts +++ b/src/main/app/utils.ts @@ -8,7 +8,7 @@ import type {BrowserWindow, Rectangle} from 'electron'; import {app, Menu, session, dialog, nativeImage, screen} from 'electron'; import isDev from 'electron-is-dev'; -import {APP_MENU_WILL_CLOSE} from 'common/communication'; +import {APP_MENU_WILL_CLOSE, MAIN_WINDOW_CREATED} from 'common/communication'; import Config from 'common/config'; import JsonFileManager from 'common/JsonFileManager'; import {Logger} from 'common/log'; @@ -38,8 +38,12 @@ const log = new Logger('App.Utils'); export function openDeepLink(deeplinkingUrl: string) { try { - MainWindow.show(); - ViewManager.handleDeepLink(deeplinkingUrl); + if (MainWindow.get()) { + MainWindow.show(); + ViewManager.handleDeepLink(deeplinkingUrl); + } else { + MainWindow.on(MAIN_WINDOW_CREATED, () => ViewManager.handleDeepLink(deeplinkingUrl)); + } } catch (err) { log.error(`There was an error opening the deeplinking url: ${err}`); } diff --git a/src/main/views/viewManager.ts b/src/main/views/viewManager.ts index 1a9e1790ca1..3de2c1596c2 100644 --- a/src/main/views/viewManager.ts +++ b/src/main/views/viewManager.ts @@ -92,9 +92,11 @@ export class ViewManager { } private init = () => { - LoadingScreen.show(); - ServerManager.getAllServers().forEach((server) => this.loadServer(server)); - this.showInitial(); + if (ServerManager.hasServers()) { + LoadingScreen.show(); + ServerManager.getAllServers().forEach((server) => this.loadServer(server)); + this.showInitial(); + } }; private handleDeveloperModeUpdated = (json: DeveloperSettings) => { From d0355cba4a480d7e492662f96a1cb41a5d6bfc7c Mon Sep 17 00:00:00 2001 From: Devin Binnie Date: Mon, 11 Nov 2024 15:52:50 -0500 Subject: [PATCH 2/2] Don't call show() before the window is created on Windows --- src/main/app/app.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/app/app.ts b/src/main/app/app.ts index e8dd4f90e86..a22684b214d 100644 --- a/src/main/app/app.ts +++ b/src/main/app/app.ts @@ -29,7 +29,6 @@ export function handleAppSecondInstance(event: Event, argv: string[]) { // Protocol handler for win32 // argv: An array of the second instance’s (command line / deep linked) arguments - MainWindow.show(); const deeplinkingURL = getDeeplinkingURL(argv); if (deeplinkingURL) { openDeepLink(deeplinkingURL);