diff --git a/main.js b/main.js index 3714f8a9c85e1..75d037eb33679 100644 --- a/main.js +++ b/main.js @@ -62,6 +62,20 @@ const mainWindow = (() => { return shell.openExternal(url); }); + // Flag to determine is user is trying to quit the whole application altogether + let quitting = false; + + // Closing the chat window should just hide it (vs. fully quitting the application) + browserWindow.on('close', (evt) => { + if (!quitting) { + evt.preventDefault(); + browserWindow.minimize(); + } + }); + + app.on('before-quit', () => quitting = true); + app.on('activate', () => browserWindow.show()); + ipcMain.on('request-visibility', (event) => { // This is how synchronous messages work in Electron // eslint-disable-next-line no-param-reassign