From 120bb09171cc1344db231ba3b6608a8d935c3206 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 2 Jan 2026 17:57:43 +0200 Subject: [PATCH] fix(pdfjs): saving doesn't account for ntxId or noteId --- apps/client/src/widgets/type_widgets/file/Pdf.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/file/Pdf.tsx b/apps/client/src/widgets/type_widgets/file/Pdf.tsx index a0114a847..8446a2585 100644 --- a/apps/client/src/widgets/type_widgets/file/Pdf.tsx +++ b/apps/client/src/widgets/type_widgets/file/Pdf.tsx @@ -24,7 +24,7 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: { }) { const iframeRef = useRef(null); const { onLoad } = useStyleInjection(iframeRef); - const historyConfig = useViewModeConfig(note, "pdfHistory"); + const historyConfig = useViewModeConfig(note, "pdfHistory"); const [ locale ] = useTriliumOption("locale"); const [ newLayout ] = useTriliumOptionBool("newLayout"); @@ -32,7 +32,9 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: { function handleMessage(event: PdfMessageEvent) { if (event.data?.type === "pdfjs-viewer-document-modified") { const blob = new Blob([event.data.data as Uint8Array], { type: note.mime }); - server.upload(`notes/${note.noteId}/file`, new File([blob], note.title, { type: note.mime }), componentId); + if (event.data.noteId === note.noteId && event.data.ntxId === noteContext.ntxId) { + server.upload(`notes/${note.noteId}/file`, new File([blob], note.title, { type: note.mime }), componentId); + } } if (event.data.type === "pdfjs-viewer-save-view-history" && event.data?.data) { @@ -187,6 +189,8 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: { const win = iframeRef.current?.contentWindow; if (win) { win.TRILIUM_VIEW_HISTORY_STORE = historyConfig.config; + win.TRILIUM_NOTE_ID = note.noteId; + win.TRILIUM_NTX_ID = noteContext.ntxId; } onLoad(); }}