aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-10-23 15:23:26 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-10-23 15:23:26 +0200
commit2ae409e1f2622b509703ed814d3aa8f4e136d09a (patch)
tree9a9cb26252a9165b6181a94492a6ddbccf65cbae /src/index.js
parentfix linting issue (diff)
downloadferdium-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/index.js')
-rw-r--r--src/index.js16
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.
20let mainWindow; 20let mainWindow;
21const settings = new Settings();
22let willQuitApp = false; 21let 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
32const isSecondInstance = app.makeSingleInstance(() => {
33 if (mainWindow) {
34 if (mainWindow.isMinimized()) mainWindow.restore();
35 mainWindow.focus();
36 }
37});
38
39if (isSecondInstance) {
40 app.quit();
41}
42
43// Initialize Settings
44const settings = new Settings();
45
32const createWindow = async () => { 46const createWindow = async () => {
33 // Remember window size 47 // Remember window size
34 const mainWindowState = windowStateKeeper({ 48 const mainWindowState = windowStateKeeper({