feat(annotations): apply sidebar lifecycle events to local store#762
Draft
jackiejou wants to merge 4 commits into
Draft
feat(annotations): apply sidebar lifecycle events to local store#762jackiejou wants to merge 4 commits into
jackiejou wants to merge 4 commits into
Conversation
Threads in PopupV2 can now edit and delete replies. Reply edits dispatch
to PUT /undoc/comments/{id} and reply deletes to DELETE
/undoc/comments/{id} via the box-ui-elements ThreadedComments client.
- Adds updateReplyAction and deleteReplyAction thunks. Both reject
upfront when the reply is not present in state so callers receive a
typed error instead of an opaque server response.
- Adds reducer cases that replace or remove the targeted reply on
fulfilled.
- Threads the canEdit permission through replyToTextMessage so the
edit affordance reflects backend permissions.
- Widens the Token type with TokenMap so consumers can pass a per-typed
file id resolver for avatar fetching.
replyToTextMessage was not setting updatedAt on the message, so the edit indicator never appeared on edited replies even though the backend returns modified_at on the comment object. The Reply type also did not declare the field.
box-annotations only emitted lifecycle events for the create flow.
Other thunks ran their API calls and updated internal state, but
withAnnotations listeners on the box-ui-elements side never fired,
so the activity feed went stale until reload.
Adds outbound eventing for five thunks following the existing
create.ts pattern:
- updateAnnotationAction emits annotations_update (covers resolve
and unresolve via annotation.status)
- deleteAnnotationAction emits annotations_delete
- createReplyAction emits annotations_reply_create
- updateReplyAction emits annotations_reply_update
- deleteReplyAction emits annotations_reply_delete
Each handler emits via the singleton eventManager with the
{ annotation, error, meta: { requestId, status } } envelope. Reply
handlers add an annotationReply field carrying the reply object.
Generalizes AsyncAction over arg/payload so each handler can type
its action precisely. Each success-phase handler short-circuits
when the necessary payload is missing instead of emitting a
contradictory success event.
Listens to inbound sidebar.* events emitted by the activity feed and applies them to the document-side redux store, keeping the in-document popup in sync with sidebar-initiated edits, replies, and resolve flows. - New SidebarEvent enum with four entries: SIDEBAR_ANNOTATION_UPDATE, SIDEBAR_REPLY_CREATE, SIDEBAR_REPLY_UPDATE, SIDEBAR_REPLY_DELETE. - Four plain createAction actions (apply*) dispatched on each event. - Four idempotent reducer cases on annotations.byId: merge for annotation update, dedupe-by-id for reply create, in-place merge for reply update, filter-by-id for reply delete. All bail when the parent annotation is missing from local state. - The annotation update reducer skips explicit-undefined payload keys so a sparse update cannot erase fields like permissions or status. - BaseAnnotator subscribes only to the success-phase events and unsubscribes in destroy(). - Annotation delete is unchanged; it continues to flow through the existing annotations_remove listener. - Middleware regression test asserts the new actions are absent from the eventing handler map.
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.
Summary
apply*actions (plaincreateAction) dispatched fromBaseAnnotatorlisteners onto matching reducer cases onannotations.byId:permissionsorstatus.reply.id.reply.id.replyId.SidebarEventenum keeps thesidebar.*event names disjoint fromEvent.annotations_removelistener andremoveAnnotationActionreducer.test.eachregression asserts the fourapply*actions never appear in the handler map._startoptimistic events); reply create dedupes byreply.idonly; reducer bails when the parent annotation is not in local state.Test plan
annotations_removelistener).apply*dispatches (loop check via redux DevTools).yarn jest --testPathPattern="(store/annotations|store/eventing|common/BaseAnnotator)"passes (146 tests across 17 suites).