From 37cdf7295918d852986efdb1197f9607fccea031 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 11 Jan 2025 19:43:10 -0800 Subject: [PATCH] refac --- src/main.ts | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/src/main.ts b/src/main.ts index 4a03673..adacc84 100644 --- a/src/main.ts +++ b/src/main.ts @@ -104,36 +104,18 @@ if (!gotTheLock) { // Wait for the renderer to finish loading mainWindow.webContents.once('did-finish-load', async () => { console.log('Renderer finished loading'); - - // Check installation and start the server - if (validateInstallation()) { - try { - SERVER_URL = await startServer(); - console.log('Server URL:', SERVER_URL); - - // Send the server URL to the renderer - mainWindow.webContents.send('main:data', { - type: 'server:url', - data: SERVER_URL - }); - } catch (error) { - console.error('Failed to start server:', error); - - // Send an error message if the server fails to start - mainWindow.webContents.send('main:data', { - type: 'server:error', - data: 'Failed to start the server' - }); - } - } else { - // No valid installation, send fallback info - mainWindow.webContents.send('main:data', { - type: 'server:url', - data: null - }); - } }); + // Check installation and start the server + if (validateInstallation()) { + try { + SERVER_URL = await startServer(); + mainWindow.loadURL(SERVER_URL); + } catch (error) { + console.error('Failed to start server:', error); + } + } + globalShortcut.register('Alt+CommandOrControl+O', () => { mainWindow?.show();