From 9a9f11c5e34324a6cae1165b6a8f5cf986d6b817 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Thu, 1 Aug 2024 13:45:03 +0800 Subject: [PATCH] Fix attachment annotation box render on non-PDF items (#4478) --- .../zotero/elements/attachmentAnnotationsBox.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/elements/attachmentAnnotationsBox.js b/chrome/content/zotero/elements/attachmentAnnotationsBox.js index 186752108a..27af270883 100644 --- a/chrome/content/zotero/elements/attachmentAnnotationsBox.js +++ b/chrome/content/zotero/elements/attachmentAnnotationsBox.js @@ -96,8 +96,6 @@ if (!this.initialized || !this.item?.isFileAttachment()) return; if (this._isAlreadyRendered()) return; - await Zotero.PDFWorker.renderAttachmentAnnotations(this.item.id); - this._body.replaceChildren(); if (!this._section.open || this._annotationItems.length === 0) { @@ -105,7 +103,19 @@ } this.hidden = false; + let imageAnnotationRendered = false; for (let annotation of this._annotationItems) { + if (!imageAnnotationRendered + && annotation.annotationType === 'image' + && !await Zotero.Annotations.hasCacheImage(annotation)) { + try { + await Zotero.PDFWorker.renderAttachmentAnnotations(annotation.parentID); + imageAnnotationRendered = true; + } + catch (e) { + Zotero.logError(e); + } + } this.addRow(annotation); } }