Skip to content

Commit 8aa6ee1

Browse files
authored
prevent app spawning multiple times (windows) (#108)
1 parent 9b45e5c commit 8aa6ee1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main.dev.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Sentry.init({
6565
});
6666

6767
let mainWindow: BrowserWindow | null;
68+
const singleInstanceLock = app.requestSingleInstanceLock();
6869
let updateStream: grpc.ClientReadableStream<ConnectionStatusUpdate> | undefined;
6970

7071
class AppUpdater {
@@ -346,4 +347,14 @@ async function init(): Promise<void> {
346347
});
347348
}
348349

349-
init();
350+
if (!singleInstanceLock) {
351+
app.quit();
352+
} else {
353+
app.on('second-instance', () => {
354+
if (mainWindow) {
355+
if (mainWindow.isMinimized()) mainWindow.restore();
356+
mainWindow.focus();
357+
}
358+
});
359+
init();
360+
}

0 commit comments

Comments
 (0)