Skip to content

Commit

Permalink
fix: exit the app properly when the main window has confirmed quit (#863
Browse files Browse the repository at this point in the history
)
  • Loading branch information
2xAA authored Jun 12, 2023
1 parent 151feb0 commit e12bbe5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/background/window-prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getMediaManager } from "./media-manager";

const isDevelopment = process.env.NODE_ENV === "development";
const isTest = process.env.CI === "e2e";
let shouldCloseMainWindowAndQuit = false;
let modVReady = false;

const windowPrefs = {
Expand Down Expand Up @@ -156,11 +155,6 @@ const windowPrefs = {

if (!isDevelopment && !isTest) {
window.on("close", async e => {
if (shouldCloseMainWindowAndQuit) {
app.quit();
return;
}

e.preventDefault();

const { response } = await dialog.showMessageBox(window, {
Expand All @@ -171,8 +165,10 @@ const windowPrefs = {
});

if (response === 0) {
shouldCloseMainWindowAndQuit = true;
window.close();
// Use .exit instead of .quit to prevent close event firing again.
// Usually .quit would be preferable, but since we only have one
// instance of the main window we can just exit.
app.exit();
}
});
}
Expand Down

0 comments on commit e12bbe5

Please sign in to comment.