diff --git a/src/index.js b/src/index.js index e7fa7da6d..b07666ba2 100644 --- a/src/index.js +++ b/src/index.js @@ -18,7 +18,6 @@ import './electron/exception'; // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow; -const settings = new Settings(); let willQuitApp = false; // Ensure that the recipe directory exists @@ -29,6 +28,21 @@ if (isWindows) { app.setAppUserModelId(appId); } +// Force single window +const isSecondInstance = app.makeSingleInstance(() => { + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore(); + mainWindow.focus(); + } +}); + +if (isSecondInstance) { + app.quit(); +} + +// Initialize Settings +const settings = new Settings(); + const createWindow = async () => { // Remember window size const mainWindowState = windowStateKeeper({