From 9fb24a0e6d9132bcaa6c38b7fe410c03f4291d8f Mon Sep 17 00:00:00 2001 From: Jonah <47046556+jwbonner@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:07:44 -0500 Subject: [PATCH] Cancel export when popup window force closed (fixes #289) --- src/main/main.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/main.ts b/src/main/main.ts index 0b38740d..2569eca2 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -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(); @@ -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 });