Fix attachment preview of the first added attachment (#3980)

Fixes #3973
This commit is contained in:
windingwind 2024-04-16 12:47:00 +08:00 committed by GitHub
parent 86ee56cfac
commit 687ba53afd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,9 +98,9 @@
notify(action, type, ids) {
if (!this._item?.isRegularItem()) return;
this.updatePreview();
this._updateAttachmentIDs().then(() => {
this.updatePreview();
let attachments = Zotero.Items.get((this._attachmentIDs).filter(id => ids.includes(id)));
if (attachments.length === 0) {
return;
@ -177,7 +177,11 @@
}
async updatePreview() {
if (!this.usePreview || !this._section.open) {
if (!this.usePreview
// Skip only when the section is manually collapsed (when there's attachment),
// This is necessary to ensure the rendering of the first added attachment
// because the section is force-collapsed if no attachment.
|| (this._attachmentIDs.length && !this._section.open)) {
return;
}
let attachment = await this._getPreviewAttachment();