diff --git a/lib/main-app.js b/lib/main-app.js index 6151c1f0..9a2c4e59 100644 --- a/lib/main-app.js +++ b/lib/main-app.js @@ -5,24 +5,23 @@ const ipc = electron.ipcMain const GhReleases = require('electron-gh-releases') const { isPackaged } = app // electron.crashReporter.start() +const singleInstance = app.requestSingleInstanceLock() var ipcServer = null var mainWindow = null -var shouldQuit = app.makeSingleInstance(function (commandLine, workingDirectory) { - if (mainWindow) { - if (process.platform === 'win32') { - mainWindow.minimize() - mainWindow.restore() - } - mainWindow.focus() - } - return true -}) - -if (shouldQuit) { +// Single Instance Lock +if (!singleInstance) { app.quit() +} else { + app.on('second-instance', () => { + // Someone tried to run a second instance, it should focus the existing instance. + if (mainWindow) { + if (!mainWindow.isVisible()) mainWindow.show() + mainWindow.focus() + } + }) } var isUpdateReady = false