-
Notifications
You must be signed in to change notification settings - Fork 325
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: use queryReactions to fetch and show reactions in OverlayReactions. #2532
Conversation
@@ -63,33 +63,6 @@ export const addReactionToLocalState = < | |||
message.reaction_groups[currentReaction.type].sum_scores - 1; | |||
} | |||
|
|||
if (!message.reaction_groups) { |
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.
There was repetitive code, hence removed.
reactions: fetchedReactions, | ||
} = useFetchReactions({ | ||
messageId, | ||
sort: { created_at: -1 }, |
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.
sort: { created_at: -1 }, | |
sort: { created_at: -1 }, |
I think we should move this to a const outside, so that inside the hook useMEmo stringify does not trigger again and again..
its a simple optimisation
const reactions = | ||
propReactions || | ||
(fetchedReactions.map((reaction) => ({ | ||
alignment: 'left', | ||
id: reaction.user?.id, | ||
image: reaction.user?.image, | ||
name: reaction.user?.name, | ||
type: reaction.type, | ||
})) as Reaction[]); |
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.
we should useMemo this I think.. so that we dont map unnecessarily if the fetched reactions are the same
🎉 This PR is included in version 5.32.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎯 Goal
This PR focuses on using the
client.queryReactions
API to show reactions in the OverlayReactions instead of what was used before(message.latest_reactions
). Optimistic fetching of reactions from local DB is present and is also handled in the PR.Note: The
reactions
type could have beenReactionsResponse
and that would make the code much cleaner but sadly that would be a breaking change so the response from the API is mapped to the existingReaction
type.Also, this PR is to be reviewed and merged once #2523 is merged.
🛠 Implementation details
🎨 UI Changes
iOS
Android
🧪 Testing
☑️ Checklist
develop
branch