Skip to content

Commit

Permalink
fix: fixes logic flow for quit confirmation (#443)
Browse files Browse the repository at this point in the history
Removes boolean from quit confirmation dialog logic

fixes #440
  • Loading branch information
2xAA authored Oct 9, 2020
1 parent c467b87 commit b68e358
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,15 @@ const windowPrefs = {

if (!isDevelopment || process.env.IS_TEST) {
window.on("close", async e => {
if (app.showExitPrompt) {
e.preventDefault(); // Prevents the window from closing
const { response } = await dialog.showMessageBox({
type: "question",
buttons: ["Yes", "No"],
message: "modV",
detail: "Are you sure you want to quit?"
});

if (!response) {
app.showExitPrompt = false;
app.quit();
}
const { response } = await dialog.showMessageBox(this, {
type: "question",
buttons: ["Yes", "No"],
message: "modV",
detail: "Are you sure you want to quit?"
});

if (response === 1) {
e.preventDefault();
}
});
}
Expand Down Expand Up @@ -364,9 +360,6 @@ function createWindow(windowName, event) {
return;
}

// Should the application promt when attempting to quit?
app.showExitPrompt = true;

let windowOptions = windowPrefs[windowName].options;

if (typeof windowPrefs[windowName].beforeCreate === "function") {
Expand Down Expand Up @@ -419,7 +412,7 @@ function createWindow(windowName, event) {
app.on("window-all-closed", () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== "darwin" || !app.showExitPrompt) {
if (process.platform !== "darwin") {
app.quit();
}
});
Expand Down

0 comments on commit b68e358

Please sign in to comment.