Use new attachment fields for annotations import

This commit is contained in:
Martynas Bagdonas 2021-01-08 15:19:15 +02:00 committed by Dan Stillman
parent ebc0ca2462
commit c13ac32ad2
2 changed files with 8 additions and 8 deletions

View file

@ -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
*/

View file

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