Skip to content

Commit

Permalink
Cancel export when popup window force closed (fixes #289)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Dec 19, 2024
1 parent 22d43c8 commit 9fb24a0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2676,6 +2676,7 @@ function createExportWindow(
// Finish setup
exportWindow.setMenu(null);
exportWindow.once("ready-to-show", parentWindow.show);
let isPreparingExport = false;
exportWindow.webContents.on("dom-ready", () => {
// Create ports on reload
const { port1, port2 } = new MessageChannelMain();
Expand Down Expand Up @@ -2719,12 +2720,18 @@ function createExportWindow(
})
.then((response) => {
if (!response.canceled) {
isPreparingExport = true;
exportWindow.destroy();
sendMessage(parentWindow, "prepare-export", { path: response.filePath, options: exportOptions });
}
});
}
});
exportWindow.on("closed", () => {
if (!isPreparingExport) {
sendMessage(parentWindow, "cancel-export");
}
});
exportWindow.on("blur", () => port2.postMessage({ isFocused: false }));
exportWindow.on("focus", () => port2.postMessage({ isFocused: true }));
port2.postMessage({ supportsAkit: supportsAkit });
Expand Down

0 comments on commit 9fb24a0

Please sign in to comment.