feat(print): display progress in toast

This commit is contained in:
Elian Doran
2025-11-21 12:24:01 +02:00
parent 6ca941e8e9
commit 586c707e51
4 changed files with 40 additions and 18 deletions

View File

@@ -139,11 +139,7 @@ export default function NoteDetail() {
useTriliumEvent("printActiveNote", () => {
if (!noteContext?.isActive() || !note) return;
toast.showPersistent({
icon: "bx bx-loader-circle bx-spin",
message: t("note_detail.printing"),
id: "printing"
});
showToast("printing");
if (isElectron()) {
const { ipcRenderer } = dynamicRequire("electron");
@@ -163,7 +159,7 @@ export default function NoteDetail() {
}
iframe.contentWindow.addEventListener("note-load-progress", (e) => {
console.log("Got ", e);
showToast("printing", e.detail.progress);
});
iframe.contentWindow.addEventListener("note-ready", () => {
@@ -326,3 +322,12 @@ function checkFullHeight(noteContext: NoteContext | undefined, type: ExtendedNot
|| noteContext?.viewScope?.viewMode === "attachments"
|| isBackendNote;
}
function showToast(type: "printing" | "exporting_pdf", progress: number = 0) {
toast.showPersistent({
icon: "bx bx-loader-circle bx-spin",
message: t("note_detail.printing"),
id: "printing",
progress
});
}