From 6146071a9054d3292f0413f55af7f5191add0e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 28 Nov 2018 16:51:04 -0300 Subject: [PATCH] enable single instance --- electron/main.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/electron/main.js b/electron/main.js index 2f831596581..474d01507e5 100644 --- a/electron/main.js +++ b/electron/main.js @@ -145,27 +145,29 @@ app.setPath('userData', path.join(homeDir, `.${appConfig.name}/app`)); // This method makes your application a Single Instance Application // https://electronjs.org/docs/api/app#apphassingleinstancelock -/* const gotTheLock = app.requestSingleInstanceLock(); - -if (!gotTheLock) { - app.quit(); - return; -} else { - app.on('second-instance', (event, argv, workingDirectory) => { - if (win) { - // Windows - Linux: Handle deeplink url - if (process.platform == 'win32' || process.platform == 'linux') { - deeplinkingUrl = argv ? argv[1] : null; - if (deeplinkingUrl) { - win.webContents.send('open-url-event', deeplinkingUrl); +if (process.platform !== 'darwin') { + const gotTheLock = app.requestSingleInstanceLock(); + + if (!gotTheLock) { + app.quit(); + return; + } else { + app.on('second-instance', (event, argv, workingDirectory) => { + if (win) { + // Windows - Linux: Handle deeplink url + if (process.platform == 'win32' || process.platform == 'linux') { + deeplinkingUrl = argv ? argv[1] : null; + if (deeplinkingUrl) { + win.webContents.send('open-url-event', deeplinkingUrl); + } } + // Someone tried to run a second instance, we should focus our window. + if (win.isMinimized()) win.restore(); + win.focus(); } - // Someone tried to run a second instance, we should focus our window. - if (win.isMinimized()) win.restore(); - win.focus(); - } - }); */ - + }); + } +} // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs.