Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions skeleton/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,29 @@ export default class App {
applySingleInstance() {
if ('singleInstance' in this.settings && this.settings.singleInstance) {
this.l.verbose('setting single instance mode');
const isSecondInstance = app.makeSingleInstance(() => {
// Someone tried to run a second instance, we should focus our window.
if (this.window) {
if (this.window.isMinimized()) {
this.window.restore();
if (semver.lt(process.versions.electron, '4.0.0')) { //https://www.electronjs.org/docs/all#appmakesingleinstance
const isSecondInstance = app.makeSingleInstance(() => {
// Someone tried to run a second instance, we should focus our window.
if (this.window) {
if (this.window.isMinimized()) {
this.window.restore();
}
this.window.focus();
}
this.window.focus();
}
});

if (isSecondInstance) {
this.l.warn('current instance was terminated because another instance is running');
app.quit();
});
} else {
app.requestSingleInstanceLock()
const isSecondInstance = app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window.
if (this.window) {
if (this.window.isMinimized()) {
this.window.restore();
}
this.window.focus();
}
this.l.warn('current instance was terminated because another instance is running');
app.quit();
});
}
}
}
Expand Down