Skip to content

Commit

Permalink
enable single instance
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbazan7 committed Nov 28, 2018
1 parent dc5c6b2 commit 6146071
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions electron/main.js
Expand Up @@ -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.
Expand Down

0 comments on commit 6146071

Please sign in to comment.