Enable Undo Retrieve Metadata when translator added note (#4267)

Closes #2977
This commit is contained in:
Abe Jellinek 2024-06-21 12:56:29 -04:00 committed by Dan Stillman
parent a054831a3a
commit d8eae4cd3b
2 changed files with 109 additions and 7 deletions

View file

@ -27,6 +27,7 @@ Zotero.RecognizeDocument = new function () {
const OFFLINE_RECHECK_DELAY = 60 * 1000;
const MAX_PAGES = 5;
const UNRECOGNIZE_TIMEOUT = 86400 * 1000;
const NOTE_EDIT_THRESHOLD = 1000;
const EPUB_MAX_SECTIONS = 5;
let _newItems = new WeakMap();
@ -169,8 +170,7 @@ Zotero.RecognizeDocument = new function () {
if (!dateModified
|| Zotero.Date.sqlToDate(dateModified, true) < new Date() - UNRECOGNIZE_TIMEOUT
|| item.dateModified != dateModified
|| item.numAttachments(true) != 1
|| item.numChildren(true) != 1) {
|| item.numAttachments(true) != 1) {
_newItems.delete(item);
return false;
}
@ -182,6 +182,13 @@ Zotero.RecognizeDocument = new function () {
return false;
}
// Notes must have been modified within one second of the item
var notes = Zotero.Items.get(item.getNotes());
if (notes.some(note => note.dateModified > dateModified + NOTE_EDIT_THRESHOLD)) {
_newItems.delete(item);
return false;
}
return true;
};