Skip to content

Do not override key of annotation when restoring from trash - #173

Open
abaevbog wants to merge 3 commits into
zotero:masterfrom
abaevbog:dont_change_annotation_key_on_undo
Open

Do not override key of annotation when restoring from trash#173
abaevbog wants to merge 3 commits into
zotero:masterfrom
abaevbog:dont_change_annotation_key_on_undo

Conversation

@abaevbog

@abaevbog abaevbog commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

Since now annotation items will just be un-deleted vs erased and recreated on undo.

Needed for zotero/zotero#5472

- if annotation trashing is supported, do not override
key of annotations when deletion is undone
- expose annotationManager.clearInterferingHistory
so that when an annotation is erased from trash, it
is removed from reader's edits history
@abaevbog
abaevbog force-pushed the dont_change_annotation_key_on_undo branch from 2600ceb to 8eee0f0 Compare August 17, 2026 00:12
Comment thread src/common/annotation-manager.js Outdated
}
// Assign new id when undeleting to reduce sync conflicts
if (!prevAnnotation) {
// Assign new id when undeleting to reduce sync conflicts. Clients that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Comment thread src/common/reader.js Outdated
// Called when the client permanently deletes annotations that are no longer
// in the view (e.g. erased from the trash), so history points referencing
// them can't be replayed and recreate them
clearAnnotationsHistory(ids) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just call this clearHistoryForAnnotations() for consistency, and since clearAnnotationsHistory() isn't really grammatically clear.

That said, could we integrate as a flag passed to unsetAnnotations()? permanentlyDeleted? Not totally necessary, but exposing this as a separate method feels a little unnecessarily finicky.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Folding clearAnnotationsHistory into unsetAnnotations does make it a bit cleaner.

After pushing this change, though, I realized that often the annotation that we are removing from history is no longer in the _annotations array of the reader (since those are removed when annotations are trashed). So when trashed annotations are erased, do we really "unset" them?

It's a mainly semantic difference of what makes more sense.

abaevbog and others added 2 commits August 17, 2026 13:39
If permanentlyDeleted flag is passed, annotations
will be removed from history after being removed
from the annotations array.
Co-authored-by: Abe Jellinek <1770299+AbeJellinek@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants