From 0c089efd8a6a4fb651d15db973239cd1fed81c81 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 14 Jan 2024 02:46:21 -0500 Subject: [PATCH] More attachment box fixes - Only try to show preview or check file existence for file attachments - Use fileExists() for file check - Show Accessed for linked-URL attachments --- chrome/content/zotero/elements/attachmentBox.js | 4 ++-- chrome/content/zotero/elements/attachmentPreview.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/elements/attachmentBox.js b/chrome/content/zotero/elements/attachmentBox.js index adfe4cbbe6..126a135022 100644 --- a/chrome/content/zotero/elements/attachmentBox.js +++ b/chrome/content/zotero/elements/attachmentBox.js @@ -259,7 +259,7 @@ let indexStatusRow = this._id('indexStatusRow'); let selectButton = this._id('select-button'); - let fileExists = await IOUtils.exists(this._item.getFilePath()); + let fileExists = this._item.isFileAttachment() && await this._item.fileExists(); let isImportedURL = this.item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_IMPORTED_URL; let isLinkedURL = this.item.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_URL; @@ -287,7 +287,7 @@ } // Access date - if (this.displayAccessed && isImportedURL) { + if (this.displayAccessed && (isImportedURL || isLinkedURL)) { let itemAccessDate = this.item.getField('accessDate'); if (itemAccessDate) { itemAccessDate = Zotero.Date.sqlToDate(itemAccessDate, true); diff --git a/chrome/content/zotero/elements/attachmentPreview.js b/chrome/content/zotero/elements/attachmentPreview.js index c8f2cc8d38..71a8360d2e 100644 --- a/chrome/content/zotero/elements/attachmentPreview.js +++ b/chrome/content/zotero/elements/attachmentPreview.js @@ -98,7 +98,7 @@ } set item(val) { - this._item = (val instanceof Zotero.Item && val.isAttachment()) ? val : null; + this._item = (val instanceof Zotero.Item && val.isFileAttachment()) ? val : null; if (this.isVisible) { this.render(); } @@ -200,7 +200,7 @@ } this._renderingItemID = itemID; let success = false; - if (this.isValidType && await IOUtils.exists(this._item.getFilePath())) { + if (this.isValidType && await this._item.fileExists()) { if (this.isReaderType) { success = await this._renderReader(); }