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 {
|
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")
|
.get("htmlDocumentConverter")
|
||||||
.convert({
|
.convert({
|
||||||
inputPath: globalFinalHtmlPath,
|
inputPath: globalFinalHtmlPath,
|
||||||
format,
|
format,
|
||||||
showDialog: true
|
showDialog: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
event.sender.send("download_success", {
|
||||||
|
path: outputPath,
|
||||||
|
format
|
||||||
|
});
|
||||||
|
|
||||||
|
new Notification({
|
||||||
|
title: "Erfolgreich gespeichert",
|
||||||
|
body: `Dokument gespeichert als .${format}`
|
||||||
|
}).show();
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Download failed:", err);
|
console.error("file_download failed:", err);
|
||||||
throw err;
|
|
||||||
|
event.sender.send("error", err.message || String(err));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user