Skip to content

Commit

Permalink
fix(background): fixes quit confirmation dialog (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
2xAA authored Nov 22, 2020
1 parent ae72f55 commit fca5085
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let mm;

let projectNames = ["default"];
let currentProject = "default";
let shouldCloseMainWindow = false;

const windowPrefs = {
colorPicker: {
Expand Down Expand Up @@ -138,15 +139,23 @@ const windowPrefs = {

if (!isDevelopment || process.env.IS_TEST) {
window.on("close", async e => {
const { response } = await dialog.showMessageBox(this, {
if (shouldCloseMainWindow) {
shouldCloseMainWindow = false;
return;
}

e.preventDefault();

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

if (response === 1) {
e.preventDefault();
if (response === 0) {
shouldCloseMainWindow = true;
window.close();
}
});
}
Expand Down

0 comments on commit fca5085

Please sign in to comment.