Skip to content

Commit e0a6f80

Browse files
committed
makes the app a single instance application
1 parent dcad6a4 commit e0a6f80

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/electron/window-manager.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var RESOURCES = path.resolve(__dirname, '../../');
2323
var DEFAULT_URL = 'file://' + path.join(RESOURCES, 'index.html#connect');
2424

2525
/**
26-
* We want want the Connect dialog window to be special
26+
* We want the Connect dialog window to be special
2727
* and for there to ever only be one instance of it
2828
* so we'll use scope to essentially make it a Singleton.
2929
*/
@@ -62,6 +62,23 @@ module.exports.create = function(opts) {
6262
'direct-write': true
6363
}
6464
});
65+
66+
// makes the application a single instance application
67+
// see "app.makeSingleInstance" in https://github.com/atom/electron/blob/master/docs/api/app.md
68+
var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory) {
69+
// Someone tried to run a second instance, we should focus our window
70+
if (_window) {
71+
if (_window.isMinimized()) _window.restore();
72+
_window.focus();
73+
}
74+
return true;
75+
});
76+
77+
if (shouldQuit) {
78+
app.quit();
79+
return;
80+
}
81+
6582
attachMenu(_window);
6683
_window.loadUrl(opts.url);
6784

0 commit comments

Comments
 (0)