From b56c153125b4523bbf7222ff1035d292bbcdc889 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 26 Jun 2026 11:04:31 -0400 Subject: [PATCH] Fix Attachment Last Read search condition by matching at attachment level Addresses #5978 --- .../zotero/xpcom/data/searchConditions.js | 3 ++- test/tests/searchTest.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/data/searchConditions.js b/chrome/content/zotero/xpcom/data/searchConditions.js index 692b9bf0cd..d969eac60f 100644 --- a/chrome/content/zotero/xpcom/data/searchConditions.js +++ b/chrome/content/zotero/xpcom/data/searchConditions.js @@ -345,7 +345,8 @@ Zotero.SearchConditions = new function () { isInTheLast: true }, table: 'itemAttachments', - field: 'lastRead' + field: 'lastRead', + level: 'attachment' }, // Deprecated diff --git a/test/tests/searchTest.js b/test/tests/searchTest.js index c6df6fe532..d4c4f83491 100644 --- a/test/tests/searchTest.js +++ b/test/tests/searchTest.js @@ -834,6 +834,23 @@ describe("Zotero.Search", function () { }); }); + describe("lastRead", function () { + it("should roll a child attachment's last-read date up to its top-level item", async function () { + var item = await createDataObject('item', { title: 'zlastread' }); + var attachment = await importPDFAttachment(item); + attachment.attachmentLastRead = Math.round(Date.now() / 1000); + await attachment.saveTx(); + + var s = new Zotero.Search(); + s.libraryID = userLibraryID; + s.addCondition('resultLevel', 'item'); + s.addCondition('lastRead', 'isInTheLast', '1 days'); + assert.sameMembers(await s.search(), [item.id]); + + await item.eraseTx(); + }); + }); + describe("fulltextContent", function () { it("should find text in HTML files", async function () { var s = new Zotero.Search();