Skip to content

Commit a82d15e

Browse files
committed
fix(type_widgets/attachments): attachments not refreshing when uploading new revision
1 parent 24b169d commit a82d15e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

apps/client/src/widgets/type_widgets/Attachment.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,19 @@ export function AttachmentDetail({ note, viewScope }: TypeWidgetProps) {
129129
function AttachmentInfo({ attachment, isFullDetail }: { attachment: FAttachment, isFullDetail?: boolean }) {
130130
const contentWrapper = useRef<HTMLDivElement>(null);
131131

132-
useEffect(() => {
132+
function refresh() {
133133
content_renderer.getRenderedContent(attachment, { imageHasZoom: isFullDetail })
134134
.then(({ $renderedContent }) => {
135135
contentWrapper.current?.replaceChildren(...$renderedContent);
136-
})
137-
}, [ attachment ]);
136+
});
137+
}
138+
139+
useEffect(refresh, [ attachment ]);
140+
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
141+
if (loadResults.getAttachmentRows().find(attachment => attachment.attachmentId)) {
142+
refresh();
143+
}
144+
});
138145

139146
async function copyAttachmentLinkToClipboard() {
140147
if (attachment.role === "image") {

0 commit comments

Comments
 (0)