fix(type_widgets/attachments): attachments not refreshing when uploading new revision

This commit is contained in:
Elian Doran 2025-11-09 14:26:32 +02:00
parent 24b169d667
commit a82d15e83d
No known key found for this signature in database

View File

@ -129,12 +129,19 @@ export function AttachmentDetail({ note, viewScope }: TypeWidgetProps) {
function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment, isFullDetail?: boolean }) { function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment, isFullDetail?: boolean }) {
const contentWrapper = useRef<HTMLDivElement>(null); const contentWrapper = useRef<HTMLDivElement>(null);
useEffect(() => { function refresh() {
content_renderer.getRenderedContent(attachment, { imageHasZoom: isFullDetail }) content_renderer.getRenderedContent(attachment, { imageHasZoom: isFullDetail })
.then(({ $renderedContent }) => { .then(({ $renderedContent }) => {
contentWrapper.current?.replaceChildren(...$renderedContent); contentWrapper.current?.replaceChildren(...$renderedContent);
}) });
}, [ attachment ]); }
useEffect(refresh, [ attachment ]);
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
if (loadResults.getAttachmentRows().find(attachment => attachment.attachmentId)) {
refresh();
}
});
async function copyAttachmentLinkToClipboard() { async function copyAttachmentLinkToClipboard() {
if (attachment.role === "image") { if (attachment.role === "image") {