From 3935152d6f86d6fe183c99e0a20bdb8a4eaa1415 Mon Sep 17 00:00:00 2001 From: Guillermo Puente Date: Wed, 10 Jun 2020 12:06:20 -0400 Subject: [PATCH] Fix close window on darwin --- public/electron.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/public/electron.js b/public/electron.js index f299869c..4fe52eeb 100644 --- a/public/electron.js +++ b/public/electron.js @@ -47,7 +47,16 @@ const createWindow = () => { mainWindow.webContents.openDevTools(); } - mainWindow.on('closed', () => (mainWindow = null)); + mainWindow.on('closed', () => mainWindow = null); + + mainWindow.on('close', (event) => { + if (app.quitting) { + mainWindow = null; + } else { + event.preventDefault(); + mainWindow.hide(); + } + }); destroyStream = registerEvents(mainWindow); }; @@ -65,5 +74,9 @@ app.on('window-all-closed', () => { app.on('activate', () => { if (!mainWindow) { createWindow(); + } else { + mainWindow.show(); } }); + +app.on('before-quit', () => app.quitting = true);