Skip to content

Commit

Permalink
Merge pull request #589 from sbsrnt/hotfix/breaking-instance
Browse files Browse the repository at this point in the history
hotfix: breaking instance on init
  • Loading branch information
Viktor Gullmark authored Oct 22, 2020
2 parents 353e44c + b4668b1 commit 721361a
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions ExilenceNextApp/public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if (!isDev) {
* Initial Declarations
*/
const mainWindow = 'main';
const gotTheLock = app.requestSingleInstanceLock()
let windows = [];
let isQuitting;
let updateAvailable;
Expand Down Expand Up @@ -96,19 +97,33 @@ function createWindow() {
/**
* App Listeners
*/
app.whenReady().then(async () => {
await createWindow();
await createTray(trayProps);
await checkForUpdates();
});

app.on('activate', async () => {
if (windows[mainWindow] === null) {
if(!gotTheLock) {
app.quit();
} else {
app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window.
if (windows[mainWindow]) {
if (windows[mainWindow].isMinimized()) windows[mainWindow].restore()
windows[mainWindow].focus()
}
})


app.whenReady().then(async () => {
await createWindow();
await createTray(trayProps);
}
});
await checkForUpdates();
});

app.on('before-quit', () => {
isQuitting = true;
});
app.on('activate', async () => {
if (windows[mainWindow] === null) {
await createWindow();
await createTray(trayProps);
}
});

app.on('before-quit', () => {
isQuitting = true;
});
}

0 comments on commit 721361a

Please sign in to comment.