From 84e566206803a7ec46453197514f7a530b123e9e Mon Sep 17 00:00:00 2001 From: meriadec Date: Thu, 5 Jul 2018 11:45:09 +0200 Subject: [PATCH] Quit app if not main instance --- src/main/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/app.js b/src/main/app.js index cab281b3..50a79bd4 100644 --- a/src/main/app.js +++ b/src/main/app.js @@ -17,6 +17,17 @@ import { terminateAllTheThings } from './terminator' // necessary to prevent win from being garbage collected let mainWindow = null +const isSecondInstance = app.makeSingleInstance(() => { + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore() + mainWindow.focus() + } +}) + +if (isSecondInstance) { + app.quit() +} + export const getMainWindow = () => mainWindow // TODO put back OSX close behavior