summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-09-21 15:05:52 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-09-26 18:01:52 +0200
commitf363c33f0b78985ff8070b911aa10e8398b62ed0 (patch)
treebad3a96be05c428ad78a40d191d84d4912bbd030 /gui
parent4bccdb86cf089aa38cd09fbfa7a023c4a18a4179 (diff)
downloadmullvadvpn-f363c33f0b78985ff8070b911aa10e8398b62ed0.tar.xz
mullvadvpn-f363c33f0b78985ff8070b911aa10e8398b62ed0.zip
Migrate to new single instance API
Diffstat (limited to 'gui')
-rw-r--r--gui/packages/desktop/src/main/index.js25
1 files changed, 10 insertions, 15 deletions
diff --git a/gui/packages/desktop/src/main/index.js b/gui/packages/desktop/src/main/index.js
index 22e3af217c..3b9a04d7f8 100644
--- a/gui/packages/desktop/src/main/index.js
+++ b/gui/packages/desktop/src/main/index.js
@@ -46,22 +46,17 @@ const ApplicationMain = {
},
_ensureSingleInstance() {
- // This callback is guaranteed to be excuted after 'ready' events have been
- // sent to the app.
- const shouldQuit = app.makeSingleInstance((_args, _workingDirectory) => {
- log.debug('Another instance was spawned, showing window');
-
- if (this._windowController) {
- this._windowController.show();
- }
- });
-
- if (shouldQuit) {
- log.info('Another instance already exists, shutting down');
- app.exit();
+ if (app.requestSingleInstanceLock()) {
+ app.on('second-instance', (event, commandLine, workingDirectory) => {
+ if (this._windowController) {
+ this._windowController.show();
+ }
+ });
+ return false;
+ } else {
+ app.quit();
+ return true;
}
-
- return shouldQuit;
},
_overrideAppPaths() {