summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-10-23 16:46:43 +0200
committerLibravatar GitHub <noreply@github.com>2017-10-23 16:46:43 +0200
commited8f3c571184bf6b8b86d4d96d2523040e6bcad6 (patch)
treea2543693e8cb99523dc40cfc08966d317a77f141
parentdisable auto-enable for auto start on macOS (diff)
parentMerge branch 'develop' into feature/single-instance-window (diff)
downloadferdium-app-ed8f3c571184bf6b8b86d4d96d2523040e6bcad6.tar.gz
ferdium-app-ed8f3c571184bf6b8b86d4d96d2523040e6bcad6.tar.zst
ferdium-app-ed8f3c571184bf6b8b86d4d96d2523040e6bcad6.zip
Merge pull request #78 from meetfranz/feature/single-instance-window
fix(App): Force Franz to use single window
-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({