aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-30 23:18:22 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-12-30 23:18:22 +0100
commit66e0a5a9e6aa6c45c2328d8fcc4d2d460abec4ce (patch)
treecc8614cd8e8dace5c575d54601020714c2019b99
parentbuild: Simplify import.meta.env handling (diff)
downloadsophie-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).
-rw-r--r--packages/main/src/index.ts16
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.
76if (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.
76const originalUserAgent = app.userAgentFallback; 84const originalUserAgent = app.userAgentFallback;
77const userAgent = originalUserAgent.replaceAll(/\s(sophie|Electron)\/\S+/g, ''); 85const userAgent = originalUserAgent.replaceAll(/\s(sophie|Electron)\/\S+/g, '');
@@ -305,13 +313,7 @@ app.on('window-all-closed', () => {
305 } 313 }
306}); 314});
307 315
308app.whenReady().then(async () => { 316app.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});