Fix Issue #807 - single instance not enforced

We were checking for single instance too late.
It needs to be done before almost anything else happens.
This commit is contained in:
Coises 2018-09-02 12:25:42 -07:00
parent 9924dff39a
commit 1e036a3d58
1 changed files with 10 additions and 20 deletions

View File

@ -1,5 +1,8 @@
const electron = require('electron');
const app = electron.app;
if (app.makeSingleInstance(restoreMainWindow)) app.quit();
const path = require('path');
const fs = require('fs');
@ -53,15 +56,13 @@ app.on('window-all-closed', () => {
}
});
app.on('ready', () => {
if (!checkSingleInstance()) {
appReady = true;
setAppOptions();
createMainWindow();
setGlobalShortcuts();
subscribePowerEvents();
deleteOldTempFiles();
hookRequestHeaders();
}
appReady = true;
setAppOptions();
createMainWindow();
setGlobalShortcuts();
subscribePowerEvents();
deleteOldTempFiles();
hookRequestHeaders();
});
app.on('open-file', (e, path) => {
e.preventDefault();
@ -114,17 +115,6 @@ app.getMainWindow = function () {
};
app.emitBackboneEvent = emitBackboneEvent;
function checkSingleInstance() {
const shouldQuit = app.makeSingleInstance((/* commandLine, workingDirectory */) => {
restoreMainWindow();
});
if (shouldQuit) {
app.quit();
}
return shouldQuit;
}
function setAppOptions() {
app.commandLine.appendSwitch('disable-background-timer-throttling');
}