From 1886849908f90fa95e2cb191e9f444bff2eb7879 Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Thu, 7 Aug 2025 12:37:40 -0700 Subject: [PATCH 1/2] do not override key of annotation on undo Needed for https://github.com/zotero/zotero/pull/5472 --- src/common/annotation-manager.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/common/annotation-manager.js b/src/common/annotation-manager.js index 26b52f229..72aa2c0c5 100644 --- a/src/common/annotation-manager.js +++ b/src/common/annotation-manager.js @@ -552,12 +552,6 @@ class AnnotationManager { if (annotation) { annotation.dateModified = (new Date()).toISOString(); } - // Assign new id when undeleting to reduce sync conflicts - if (!prevAnnotation) { - let newID = this._generateObjectKey(); - mapping.set(annotation.id, newID); - annotation.id = newID; - } allAnnotations.set(id, annotation); this._unsavedAnnotations.set(id, annotation); } @@ -585,12 +579,6 @@ class AnnotationManager { if (annotation) { annotation.dateModified = (new Date()).toISOString(); } - // Assign new id when undeleting to reduce sync conflicts - if (!prevAnnotation) { - let newID = this._generateObjectKey(); - mapping.set(annotation.id, newID); - annotation.id = newID; - } allAnnotations.set(id, annotation); this._unsavedAnnotations.set(id, annotation); } From 2600ceb757f559a2f469d5cfa05d650826cd60bb Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Thu, 7 Aug 2025 13:54:46 -0700 Subject: [PATCH 2/2] expose annotationManager.clearInterferingHistory So that when an annotation is erased from trash, it can also be removed from edits history. --- src/common/annotation-manager.js | 4 ++-- src/common/reader.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/annotation-manager.js b/src/common/annotation-manager.js index 72aa2c0c5..d9371a33d 100644 --- a/src/common/annotation-manager.js +++ b/src/common/annotation-manager.js @@ -54,7 +54,7 @@ class AnnotationManager { this._annotations.push(annotation); } this._annotations.sort((a, b) => (a.sortIndex > b.sortIndex) - (a.sortIndex < b.sortIndex)); - this._clearInterferingHistory(annotations.map(x => x.id)); + this.clearInterferingHistory(annotations.map(x => x.id)); this.render(); } @@ -591,7 +591,7 @@ class AnnotationManager { return true; } - _clearInterferingHistory(affectedAnnotationIDs) { + clearInterferingHistory(affectedAnnotationIDs) { for (let i = this._undoStack.length - 1; i >= 0; i--) { if (affectedAnnotationIDs.some(id => this._undoStack[i].has(id))) { this._undoStack = this._undoStack.slice(i + 1); diff --git a/src/common/reader.js b/src/common/reader.js index 9857bd60f..1dbb50dbd 100644 --- a/src/common/reader.js +++ b/src/common/reader.js @@ -736,6 +736,10 @@ class Reader { this._annotationManager.unsetAnnotations(ids); } + clearAnnotationsEditHistory(ids) { + this._annotationManager.clearInterferingHistory(ids); + } + openContextMenu(params) { this._onBringReaderToFront?.(true); this._updateState({ contextMenu: params });