Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(type_widgets/attachments): attachments not refreshing when uploading new revision
Elian Dorana82d15e83d55
diff --git a/apps/client/src/widgets/type_widgets/Attachment.tsx b/apps/client/src/widgets/type_widgets/Attachment.tsxindex 369844b5f7..3fdc60e932 100644--- a/apps/client/src/widgets/type_widgets/Attachment.tsx+++ b/apps/client/src/widgets/type_widgets/Attachment.tsx@@ -129,12 +129,19 @@ export function AttachmentDetail({ note, viewScope }: TypeWidgetProps) {function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment, isFullDetail?: boolean }) {const contentWrapper = useRef<HTMLDivElement>(null);- useEffect(() => {+ function refresh() {content_renderer.getRenderedContent(attachment, { imageHasZoom: isFullDetail }).then(({ $renderedContent }) => {contentWrapper.current?.replaceChildren(...$renderedContent);- })- }, [ attachment ]);+ });+ }++ useEffect(refresh, [ attachment ]);+ useTriliumEvent("entitiesReloaded", ({ loadResults }) => {+ if (loadResults.getAttachmentRows().find(attachment => attachment.attachmentId)) {+ refresh();+ }+ });async function copyAttachmentLinkToClipboard() {if (attachment.role === "image") {