mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Refactor file download handling to improve error management and user notifications
This commit is contained in:
@@ -225,20 +225,42 @@ electron.ipcMain.on("file_submit", async (event, args) => {
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle("file_download", async () => {
|
||||
electron.ipcMain.on("file_download", async (event) => {
|
||||
try {
|
||||
const format = globalArgs.document.outputType.replace('.', '').toLowerCase();
|
||||
if (!globalFinalHtmlPath) {
|
||||
throw new Error("No document generated yet");
|
||||
}
|
||||
|
||||
return await mapFunctions
|
||||
const format = String(globalArgs?.document?.outputType || "")
|
||||
.replace('.', '')
|
||||
.toLowerCase();
|
||||
|
||||
if (!format) {
|
||||
throw new Error("No output format selected");
|
||||
}
|
||||
|
||||
const outputPath = await mapFunctions
|
||||
.get("htmlDocumentConverter")
|
||||
.convert({
|
||||
inputPath: globalFinalHtmlPath,
|
||||
format,
|
||||
showDialog: true
|
||||
});
|
||||
|
||||
event.sender.send("download_success", {
|
||||
path: outputPath,
|
||||
format
|
||||
});
|
||||
|
||||
new Notification({
|
||||
title: "Erfolgreich gespeichert",
|
||||
body: `Dokument gespeichert als .${format}`
|
||||
}).show();
|
||||
|
||||
} catch (err) {
|
||||
console.error("Download failed:", err);
|
||||
throw err;
|
||||
console.error("file_download failed:", err);
|
||||
|
||||
event.sender.send("error", err.message || String(err));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user