From 4134e5054a13d08341ebcf5834206f106e108429 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 29 Dec 2025 17:02:22 +0200 Subject: [PATCH] fix(client/pdf): not refreshing when uploading new revision --- apps/client/src/widgets/type_widgets/File.tsx | 2 +- apps/client/src/widgets/type_widgets/file/Pdf.tsx | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/File.tsx b/apps/client/src/widgets/type_widgets/File.tsx index def25cbab..b720d6a0d 100644 --- a/apps/client/src/widgets/type_widgets/File.tsx +++ b/apps/client/src/widgets/type_widgets/File.tsx @@ -16,7 +16,7 @@ export default function FileTypeWidget({ note, parentComponent }: TypeWidgetProp if (blob?.content) { return ; } else if (note.mime === "application/pdf") { - return ; + return ; } else if (note.mime.startsWith("video/")) { return ; } else if (note.mime.startsWith("audio/")) { diff --git a/apps/client/src/widgets/type_widgets/file/Pdf.tsx b/apps/client/src/widgets/type_widgets/file/Pdf.tsx index 5ffb92d34..5d2767bb9 100644 --- a/apps/client/src/widgets/type_widgets/file/Pdf.tsx +++ b/apps/client/src/widgets/type_widgets/file/Pdf.tsx @@ -1,6 +1,7 @@ import { RefObject } from "preact"; import { useCallback, useEffect, useRef } from "preact/hooks"; +import FBlob from "../../../entities/fblob"; import FNote from "../../../entities/fnote"; import server from "../../../services/server"; import { useViewModeConfig } from "../../collections/NoteList"; @@ -12,8 +13,9 @@ const VARIABLE_WHITELIST = new Set([ "main-text-color" ]); -export default function PdfPreview({ note, componentId }: { +export default function PdfPreview({ note, blob, componentId }: { note: FNote, + blob: FBlob | null | undefined, componentId: string | undefined; }) { const iframeRef = useRef(null); @@ -36,7 +38,14 @@ export default function PdfPreview({ note, componentId }: { return () => { window.removeEventListener("message", handleMessage); }; - }, [ note, historyConfig ]); + }, [ note, historyConfig, componentId, blob ]); + + // Refresh when blob changes. + useEffect(() => { + if (iframeRef.current?.contentWindow) { + iframeRef.current.contentWindow.location.reload(); + } + }, [ blob ]); return (historyConfig &&