diff options
author | 2021-12-30 23:18:22 +0100 | |
---|---|---|
committer | 2021-12-30 23:18:22 +0100 | |
commit | 66e0a5a9e6aa6c45c2328d8fcc4d2d460abec4ce (patch) | |
tree | cc8614cd8e8dace5c575d54601020714c2019b99 /packages/main/src/index.ts | |
parent | build: Simplify import.meta.env handling (diff) | |
download | sophie-66e0a5a9e6aa6c45c2328d8fcc4d2d460abec4ce.tar.gz sophie-66e0a5a9e6aa6c45c2328d8fcc4d2d460abec4ce.tar.zst sophie-66e0a5a9e6aa6c45c2328d8fcc4d2d460abec4ce.zip |
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).
Diffstat (limited to 'packages/main/src/index.ts')
-rw-r--r-- | packages/main/src/index.ts | 16 |
1 files 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( | |||
72 | 'HardwareMediaKeyHandling,MediaSessionService', | 72 | 'HardwareMediaKeyHandling,MediaSessionService', |
73 | ); | 73 | ); |
74 | 74 | ||
75 | // It doesn't seem to cause a race condition to start installing the extensions this early. | ||
76 | if (isDevelopment) { | ||
77 | app.whenReady().then(installDevToolsExtensions).catch((err) => { | ||
78 | console.error('Failed to install devtools extensions', err); | ||
79 | process.exit(1); | ||
80 | }); | ||
81 | } | ||
82 | |||
75 | // Remove sophie and electron from the user-agent string to avoid detection. | 83 | // Remove sophie and electron from the user-agent string to avoid detection. |
76 | const originalUserAgent = app.userAgentFallback; | 84 | const originalUserAgent = app.userAgentFallback; |
77 | const userAgent = originalUserAgent.replaceAll(/\s(sophie|Electron)\/\S+/g, ''); | 85 | const userAgent = originalUserAgent.replaceAll(/\s(sophie|Electron)\/\S+/g, ''); |
@@ -305,13 +313,7 @@ app.on('window-all-closed', () => { | |||
305 | } | 313 | } |
306 | }); | 314 | }); |
307 | 315 | ||
308 | app.whenReady().then(async () => { | 316 | app.whenReady().then(createWindow).catch((err) => { |
309 | if (isDevelopment) { | ||
310 | await installDevToolsExtensions(); | ||
311 | } | ||
312 | |||
313 | return createWindow(); | ||
314 | }).catch((err) => { | ||
315 | console.error('Failed to create window', err); | 317 | console.error('Failed to create window', err); |
316 | process.exit(1); | 318 | process.exit(1); |
317 | }); | 319 | }); |