Fix Attachment Last Read search condition by matching at attachment level

Addresses #5978
This commit is contained in:
Dan Stillman 2026-06-26 11:04:31 -04:00
parent 2717aafedd
commit b56c153125
2 changed files with 19 additions and 1 deletions

View file

@ -345,7 +345,8 @@ Zotero.SearchConditions = new function () {
isInTheLast: true
},
table: 'itemAttachments',
field: 'lastRead'
field: 'lastRead',
level: 'attachment'
},
// Deprecated

View file

@ -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();