mirror of
https://github.com/finos/SymphonyElectron.git
synced 2026-10-25 14:20:04 -05:00
only allow single instance of app (#68)
This commit is contained in:
1 parent
5d3377ec02
commit
f8037ffd66
1 file changed
+17
-2
+17
-2
@@ -8,7 +8,6 @@ const squirrelStartup = require('electron-squirrel-startup');
|
||||
const { getConfigField } = require('./config.js');
|
||||
const { isMac, isDevEnv } = require('./utils/misc.js');
|
||||
|
||||
|
||||
// exit early for squirrel installer
|
||||
if (squirrelStartup) {
|
||||
return;
|
||||
@@ -19,9 +18,25 @@ require('./mainApiMgr.js');
|
||||
// monitor memory of main process
|
||||
require('./memoryMonitor.js');
|
||||
|
||||
|
||||
const windowMgr = require('./windowMgr.js');
|
||||
|
||||
// only allow a single instance of app.
|
||||
const shouldQuit = app.makeSingleInstance(() => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
let mainWin = windowMgr.getMainWindow();
|
||||
if (mainWin) {
|
||||
if (mainWin.isMinimized()) {
|
||||
mainWin.restore();
|
||||
}
|
||||
mainWin.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// quit if another instance is already running
|
||||
if (shouldQuit) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called when Electron has finished
|
||||
* initialization and is ready to create browser windows.
|
||||
|
||||
Reference in new issue
Block a user