From 66e0a5a9e6aa6c45c2328d8fcc4d2d460abec4ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Marussy?= Date: Thu, 30 Dec 2021 23:18:22 +0100 Subject: refactor: Install devtools extensions earlier This doesn't seem to cause any race conditions (except for the warnings that appear even if we install the extensions before initializing the main window and are ignored by yarn watch). --- packages/main/src/index.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index f8b6787..c258481 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts @@ -72,6 +72,14 @@ app.commandLine.appendSwitch( 'HardwareMediaKeyHandling,MediaSessionService', ); +// It doesn't seem to cause a race condition to start installing the extensions this early. +if (isDevelopment) { + app.whenReady().then(installDevToolsExtensions).catch((err) => { + console.error('Failed to install devtools extensions', err); + process.exit(1); + }); +} + // Remove sophie and electron from the user-agent string to avoid detection. const originalUserAgent = app.userAgentFallback; const userAgent = originalUserAgent.replaceAll(/\s(sophie|Electron)\/\S+/g, ''); @@ -305,13 +313,7 @@ app.on('window-all-closed', () => { } }); -app.whenReady().then(async () => { - if (isDevelopment) { - await installDevToolsExtensions(); - } - - return createWindow(); -}).catch((err) => { +app.whenReady().then(createWindow).catch((err) => { console.error('Failed to create window', err); process.exit(1); }); -- cgit v1.2.3