From 90634fc5c8deacf209528ea8d59df2c3892b3bb3 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Fri, 17 May 2024 13:12:32 -0400 Subject: [PATCH] numDistinctFileAttachmentsForLabel: Filter best attachment --- chrome/content/zotero/xpcom/data/items.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/items.js b/chrome/content/zotero/xpcom/data/items.js index 4f0a034961..94d50ce274 100644 --- a/chrome/content/zotero/xpcom/data/items.js +++ b/chrome/content/zotero/xpcom/data/items.js @@ -1834,7 +1834,7 @@ Zotero.Items = function() { * array of items (which can include both parent and child items) in order to display a menu * label (e.g., "Show File" or "Show Files") * - * @param {[Zotero.Item]} + * @param {[Zotero.Item]} items * @param {Function} filter - An additional filter function to run on file attachment items to * determine if they qualify * @return {Integer} - 0, 1, or 2, where 2 means >1 @@ -1849,7 +1849,8 @@ Zotero.Items = function() { // multiple files, but getBestAttachment() is asynchronous and we need to do this // synchronously, so try to use the cached best-attachment state let { key } = item.getBestAttachmentStateCached(); - if (key) { + let bestAttachment = key && Zotero.Items.getByLibraryAndKey(item.libraryID, key); + if (bestAttachment && filter(bestAttachment)) { if (foundKey) { if (key == foundKey) { continue;