-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(comments): implement reactions #5409
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
Full Report@sanity/diff
@sanity/block-tools
@sanity/types
sanity/desk
@sanity/portable-text-editor
@sanity/mutator
@sanity/cli
@sanity/schema/_internal
@sanity/util/paths
sanity/router
@sanity/util/legacyDateFormat
@sanity/schema
sanity/structure
sanity/cli
@sanity/vision
@sanity/util/fs
sanity/_internal
sanity/_internalBrowser
@sanity/util/content
sanity
|
Component Testing Report Updated Jan 19, 2024 3:52 PM (UTC)
|
7f65404
to
7269fa6
Compare
d0c497a
to
5237021
Compare
0867838
to
6fe8f11
Compare
packages/sanity/src/structure/comments/src/hooks/use-comment-operations/removeOperation.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks @hermanwikner
Left a suggestion and some questions, but none are blockers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work @hermanwikner!
* feat(comments): add reaction components * dev(test-studio): add comment reactions workshop stories * feat(comments): comment reaction operation and data handling * feat(comments): add reactions to comments plugin * test(comments): utility function for merging two lists of comments * feat(comments): pass `readOnly` value to reactions * refactor(comments): simplify reaction users list * fix: force emoji-specific fonts, prefer buttons over cards, minor styling updates (#5524) * fix(comments): use `TooltipDelayGroupProvider` from ui-components --------- Co-authored-by: Robin Pyon <[email protected]>
Description
This pull request introduces reactions to the comments feature. In the first iteration, there will be a fixed set of reactions to select from, however, in future iterations, we may introduce the complete palette of reaction options. The reactions are stored in the comment document in the 'reactions' array. Each individual reaction is an object with the following properties:
_key
- A unique key for the reaction. The key is constructed by combining the user ID and the short name of the reaction.shortName
- The short name of the reaction. The short names follow the naming convention listed here.userId
- The ID of the user who added the reaction.addedAt
- The date when the reaction was added.Why is the
_optimisticState
needed?This flag is required to ensure that reactions removed optimistically but not yet processed on the server are not displayed. This scenario arises when a user removes Reaction A and, while the API request for that removal is still processing, removes Reaction B. There is a chance that Reaction B might temporarily reappear in the UI when the updated list of reactions is received. This is because the updated list, received after the removal of Reaction A, may not yet reflect the removal of Reaction B. Consequently, Reaction B might temporarily reappear in the UI until the updated list, including the removal of Reaction B, is received.
To address this issue, we utilize the
_optimisticState
flag to track the removal or addition of reactions locally. When the server responds with an updated list of reactions, we filter out reactions marked with the_optimisticState
set to "removed." This prevents reactions that were removed optimistically but are still being processed from reappearing in the UI.What to review
Notes for release
Make it possible to react to comments