diff --git a/app/main.ts b/app/main.ts index d8125d8..c715f96 100644 --- a/app/main.ts +++ b/app/main.ts @@ -46,14 +46,7 @@ app.on('will-finish-launching', function () { if (win) { setTimeout(() => { win.webContents.send('file-open-system', fileToLoad); - }, 2500); - } else { - // if win is not ready, wait for it - app.once('browser-window-created', () => { - setTimeout(() => { - win.webContents.send('file-open-system', fileToLoad); - }, 2500); - }); + }, 500); } } }); @@ -107,6 +100,13 @@ function createWindow(): BrowserWindow { win.loadURL(url.href); } + // Traiter le fichier ouvert après que la fenêtre soit prête + if (fileToLoad) { + win.webContents.on('did-finish-load', () => { + win.webContents.send('open-file', fileToLoad); + }); + } + // Emitted when the window is closed. win.on('closed', () => { // Dereference the window object, usually you would store window