Skip to content

Build your personal knowledge base with Trilium Notes

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.tsx
index 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") {