From 2ae409e1f2622b509703ed814d3aa8f4e136d09a Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Mon, 23 Oct 2017 15:23:26 +0200 Subject: fix(App): Force Franz to use single window Fixes #29 --- src/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/index.js') 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({ -- cgit v1.2.3-70-g09d2