diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-10-23 15:23:26 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-10-23 15:23:26 +0200 |
commit | 2ae409e1f2622b509703ed814d3aa8f4e136d09a (patch) | |
tree | 9a9cb26252a9165b6181a94492a6ddbccf65cbae /src | |
parent | fix linting issue (diff) | |
download | ferdium-app-2ae409e1f2622b509703ed814d3aa8f4e136d09a.tar.gz ferdium-app-2ae409e1f2622b509703ed814d3aa8f4e136d09a.tar.zst ferdium-app-2ae409e1f2622b509703ed814d3aa8f4e136d09a.zip |
fix(App): Force Franz to use single window
Fixes #29
Diffstat (limited to 'src')
-rw-r--r-- | src/index.js | 16 |
1 files changed, 15 insertions, 1 deletions
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'; | |||
18 | // Keep a global reference of the window object, if you don't, the window will | 18 | // Keep a global reference of the window object, if you don't, the window will |
19 | // be closed automatically when the JavaScript object is garbage collected. | 19 | // be closed automatically when the JavaScript object is garbage collected. |
20 | let mainWindow; | 20 | let mainWindow; |
21 | const settings = new Settings(); | ||
22 | let willQuitApp = false; | 21 | let willQuitApp = false; |
23 | 22 | ||
24 | // Ensure that the recipe directory exists | 23 | // Ensure that the recipe directory exists |
@@ -29,6 +28,21 @@ if (isWindows) { | |||
29 | app.setAppUserModelId(appId); | 28 | app.setAppUserModelId(appId); |
30 | } | 29 | } |
31 | 30 | ||
31 | // Force single window | ||
32 | const isSecondInstance = app.makeSingleInstance(() => { | ||
33 | if (mainWindow) { | ||
34 | if (mainWindow.isMinimized()) mainWindow.restore(); | ||
35 | mainWindow.focus(); | ||
36 | } | ||
37 | }); | ||
38 | |||
39 | if (isSecondInstance) { | ||
40 | app.quit(); | ||
41 | } | ||
42 | |||
43 | // Initialize Settings | ||
44 | const settings = new Settings(); | ||
45 | |||
32 | const createWindow = async () => { | 46 | const createWindow = async () => { |
33 | // Remember window size | 47 | // Remember window size |
34 | const mainWindowState = windowStateKeeper({ | 48 | const mainWindowState = windowStateKeeper({ |