Conversation
Contributor
cubap
reviewed
Feb 18, 2026
Member
cubap
left a comment
There was a problem hiding this comment.
It looks like this does more than it should. Feel free to disagree, but I didn't want to just approve it.
| const pageID = page["@id"] ?? page.id | ||
| const mod = await fetch(`${TPEN.servicesURL}/project/${TPEN.activeProject._id}/page/${pageID.split("/").pop()}`, { | ||
| let mod | ||
| try { |
Member
There was a problem hiding this comment.
This is weird. The fetch.then.catch is replaced with a try{fetch.then}catch{} and it looks like nothing is really changed until after this block around line 1109.
Member
Author
There was a problem hiding this comment.
It believed that the try/catch was more explicit and I also think it thought that was the most reliable way to stop code execution. In practice the old way works the same, so I reverted this change.
| message: "Could not delete all annotations.", | ||
| status: "error" | ||
| }) | ||
| } finally { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #334
Summary
Fixes a data synchronization bug in the annotator where cached annotation data fell out of sync with the server after saves. This caused subsequent saves (without a page refresh) to send stale IDs, producing duplicate or incorrect annotations on the server. Also fixes a button-mashing bug on "Delete All Annotations".
Changes
Improved annotation matching after save
The previous merge logic matched server response items to local items by
targetstring equality, which broke when targets were objects (expanded selectors). The new logic matches by annotationidfirst (for previously-saved annotations), then falls back to matching byselector.value(for newly-created annotations that don't yet have a server-assigned ID).Post-save state sync with Annotorious
After a successful save, the component now:
#resolvedAnnotationPagewith the merged server response (including new IDs)This ensures subsequent saves use the correct server-assigned IDs instead of stale local ones.
Refactored error handling
Replaced the
.then().catch()promise chain with an explicittry/catcharound the fetch call. This makes the error boundary clear — post-save sync code only executes on a successful server response.Moved
$isDirtyreset$isDirty = falseis now set after the Annotorious sync completes rather than at the end of the method, ensuring the page isn't marked clean if the sync fails.Prevented button-mashing on "Delete All Annotations"
The delete button now disables itself and shows "deleting. please wait..." while the async operation runs. Both
saveAnnotations()andclearColumnsServerSide()are wrapped in a singletry/catchso errors from either are handled. Afinallyblock re-enables the button regardless of outcome.Test plan
Start without lines. Draw a single column and click "Save Annotations". Note the state of the AnnotationPage after the save completes. Without refreshing the page, draw a second column and click "Save Annotations". Compare the state of the AnnotationPage after this save with the state of the AnnotationPage after the first save. The first Annotation should have persisted and should have the same URI.