Skip to content

Skip replacing annotations with unsaved local changes in setAnnotations()#184

Open
skalthoff wants to merge 1 commit intozotero:masterfrom
skalthoff:fix-setAnnotations-unsaved-rerender
Open

Skip replacing annotations with unsaved local changes in setAnnotations()#184
skalthoff wants to merge 1 commit intozotero:masterfrom
skalthoff:fix-setAnnotations-unsaved-rerender

Conversation

@skalthoff
Copy link
Copy Markdown
Contributor

Summary

  • Fix setAnnotations() unconditionally replacing annotation objects that have unsaved local changes, causing unnecessary re-renders that visually disrupt in-progress ink/image annotations
  • Skip annotations whose ID exists in _unsavedAnnotations — the local version is authoritative until saved
  • Also prevents locally deleted annotations (null entries in _unsavedAnnotations) from being resurrected by incoming updates

Test plan

  • Start drawing an ink annotation, trigger setAnnotations() externally (e.g. via sync) — in-progress drawing should not be disrupted
  • Verify externally-updated annotations not in _unsavedAnnotations still render correctly
  • Verify locally deleted annotations are not resurrected by incoming setAnnotations() calls

Fixes #106

…ns()

When setAnnotations() receives annotations from the client side (e.g.
during sync), it unconditionally replaces all matching annotation
objects. If an annotation has unsaved local changes tracked in
_unsavedAnnotations, this replacement triggers unnecessary re-renders
due to broken reference identity, visually disrupting in-progress ink
and image annotations.

Skip annotations whose ID exists in _unsavedAnnotations, since the
local version is authoritative until saved. This covers both locally
modified annotations (non-null entries) and locally deleted annotations
(null entries), preventing resurrection of deleted annotations.

Fixes zotero#106
@AbeJellinek
Copy link
Copy Markdown
Member

@mrtcode: I think this looks OK, but could you take a look?

@mrtcode
Copy link
Copy Markdown
Member

mrtcode commented Mar 19, 2026

@skalthoff Should _clearInterferingHistory() here be limited to IDs that were actually applied?

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.

Avoid re-rendering unsaved ink/image annotations each time setAnnotations is called

3 participants