diff --git a/chrome/content/zotero/xpcom/pdfWorker/manager.js b/chrome/content/zotero/xpcom/pdfWorker/manager.js index 520044f1b2..8a911c0558 100644 --- a/chrome/content/zotero/xpcom/pdfWorker/manager.js +++ b/chrome/content/zotero/xpcom/pdfWorker/manager.js @@ -242,23 +242,24 @@ class PDFWorker { annotation.key = Zotero.DataObjectUtilities.generateKey(); await Zotero.Annotations.saveFromJSON(attachment, annotation); } - Zotero.PDF.hasUnmachedAnnotations[itemID] = false; + attachment.attachmentHasUnimportedAnnotations = false; } else { - Zotero.PDF.hasUnmachedAnnotations[itemID] = !!annotations.length; + attachment.attachmentHasUnimportedAnnotations = !!annotations.length; } for (let reader of Zotero.Reader._readers) { if (reader._itemID === itemID) { - reader.toggleImportPrompt(!!Zotero.PDF.hasUnmachedAnnotations[itemID]); + reader.toggleImportPrompt(attachment.attachmentHasUnimportedAnnotations); } } - Zotero.PDF.dateChecked[itemID] = Zotero.Date.dateToISO(new Date()); + attachment.attachmentLastProcessedModificationTime = await attachment.attachmentModificationTime; + await attachment.saveTx(); return annotations.length; }); } /** - * Import children PDF attachment annotations + * Import annotations for each PDF attachment of parent item * * @param {Zotero.Item} item */ diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index fce4018413..83c192c579 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -46,7 +46,7 @@ class ReaderInstance { annotations, state, location, - promptImport: !!Zotero.PDF.hasUnmachedAnnotations[this._itemID], + promptImport: item.attachmentHasUnimportedAnnotations, showItemPaneToggle: this._showItemPaneToggle, sidebarWidth: this._sidebarWidth, sidebarOpen: this._sidebarOpen, @@ -811,8 +811,7 @@ class Reader { async triggerAnnotationsImportCheck(itemID) { let item = await Zotero.Items.getAsync(itemID); let mtime = await item.attachmentModificationTime; - let dateModified = Zotero.Date.dateToISO(new Date(mtime)); - if (!Zotero.PDF.dateChecked[itemID] || Zotero.PDF.dateChecked[itemID] < dateModified) { + if (item.attachmentLastProcessedModificationTime < mtime) { await Zotero.PDFWorker.import(itemID, false); } }