mirror of
https://github.com/zadam/trilium.git
synced 2026-01-02 12:44:25 +01:00
fix(client/pdf): not refreshing when uploading new revision
This commit is contained in:
parent
bb374a5ce2
commit
4134e5054a
@ -16,7 +16,7 @@ export default function FileTypeWidget({ note, parentComponent }: TypeWidgetProp
|
||||
if (blob?.content) {
|
||||
return <TextPreview content={blob.content} />;
|
||||
} else if (note.mime === "application/pdf") {
|
||||
return <PdfPreview note={note} componentId={parentComponent?.componentId} />;
|
||||
return <PdfPreview blob={blob} note={note} componentId={parentComponent?.componentId} />;
|
||||
} else if (note.mime.startsWith("video/")) {
|
||||
return <VideoPreview note={note} />;
|
||||
} else if (note.mime.startsWith("audio/")) {
|
||||
|
||||
@ -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<HTMLIFrameElement>(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 &&
|
||||
<iframe
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user