Skip to content

Commit

Permalink
Merge branch 'master' of github.com:standardnotes/desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Jun 14, 2019
2 parents 15db353 + 2fc640d commit c253ec8
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,29 @@ app.on('activate', function() {
updateManager.checkForUpdate();
});

const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
// feature flag: https://github.com/electron/electron/blob/master/docs/api/breaking-changes.md#appmakesingleinstance
const hasRequestSingleInstanceLock = app.requestSingleInstanceLock ? true : false;
let isSecondInstance = null;

// Someone tried to run a second instance, we should focus our window.
const handleSecondInstance = (argv, cwd) => {
if (win) {
if (win.isMinimized()) win.restore()
win.focus()
}
})
}

if (hasRequestSingleInstanceLock) {
isSecondInstance = !app.requestSingleInstanceLock()

app.on('second-instance', (event, argv, cwd) => {
handleSecondInstance(argv, cwd)
})
} else {
isSecondInstance = app.makeSingleInstance((argv, cwd) => {
handleSecondInstance(argv, cwd)
})
}

app.on('ready', function(){

Expand Down

0 comments on commit c253ec8

Please sign in to comment.