fix: message reactions syncing across devices#186
Open
adityashirsatrao007 wants to merge 10 commits into
Open
Conversation
Contributor
|
@adityashirsatrao007 is attempting to deploy a commit to the Sunil Kumar's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds emoji reactions to both server channel messages and direct messages, with realtime updates via Socket.IO. Also improves socket reconnection by re-joining rooms on connect.
Changes:
- New
toggle_reactionandtoggle_dm_reactionendpoints plus schema additions forreactionsarrays. - Frontend UI (emoji picker + reaction chips) and socket listeners (
reaction_updated,dm_reaction_updated) inValidChat.jsxandDirectMessage.jsx. - Re-emit
join_*/get_useridon socketconnectto handle reconnection.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| server/src/models/Chat.js | Add reactions subschema to channel messages. |
| server/src/models/DirectMessageThread.js | Add reactions subschema to DM messages. |
| server/src/routes/chat.js | Add toggle_reaction endpoint. |
| server/src/routes/directMessages.js | Add toggle_dm_reaction endpoint. |
| frontend/src/components/chat/messages/ValidChat.jsx | Add reaction UI, picker, and socket listener; re-join channel on reconnect. |
| frontend/src/components/directMessages/DirectMessage.jsx | Add DM reaction UI, picker, and socket listener. |
| frontend/src/components/chat/serverSidebar/Navbar2ChatValid.jsx | Re-join server room on socket reconnect. |
| frontend/src/components/notifications/NotificationListener.jsx | Re-emit get_userid on socket reconnect. |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+299
to
+308
| router.post("/toggle_reaction", async (req, res) => { | ||
| const { server_id, channel_id, timestamp, emoji } = req.body; | ||
| const user = getAuthorizedUser(req, res); | ||
| if (!user) return; | ||
| const userId = user.id; | ||
|
|
||
| try { | ||
| const chatDoc = await Chat.findOne({ | ||
| server_id, | ||
| "channels.channel_id": channel_id, |
Comment on lines
+32
to
+36
| const emojiPickerRef = useRef(null); | ||
|
|
||
| useEffect(() => { | ||
| setShowEmojiPicker(null); | ||
| }, [channel_id]); |
Comment on lines
+291
to
+300
| io.to(friend_id).emit("dm_reaction_updated", { | ||
| timestamp, | ||
| reactions: message.reactions, | ||
| friend_id: user.id, | ||
| }); | ||
| io.to(user.id).emit("dm_reaction_updated", { | ||
| timestamp, | ||
| reactions: message.reactions, | ||
| friend_id, | ||
| }); |
Comment on lines
+362
to
+364
| <div className="ml-auto flex items-center gap-1 opacity-0 transition group-hover:opacity-100 group-focus-within:opacity-100"> | ||
| <div className="relative"> | ||
| <button |
Comment on lines
+387
to
+389
| </div> | ||
| {mine ? ( | ||
| <div className="ml-auto flex items-center gap-1 opacity-0 transition group-hover:opacity-100 group-focus-within:opacity-100"> | ||
| <div className="flex items-center gap-1"> |
Comment on lines
412
to
+413
| ) : null} | ||
| </div> |
Comment on lines
+394
to
+398
| <div className={["absolute -top-2 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100", mine ? "right-10" : "left-0"].join(" ")}> | ||
| <button | ||
| type="button" | ||
| className="rounded-xl border border-white/10 bg-zinc-950/70 p-1.5 text-white/65 shadow-soft backdrop-blur transition hover:bg-zinc-950/85 hover:text-white" | ||
| onClick={() => setShowEmojiPicker(showEmojiPicker === message.timestamp ? null : message.timestamp)} |
Comment on lines
+347
to
+350
| } catch (err) { | ||
| res.status(500).json({ status: 500 }); | ||
| } | ||
| }); |
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.
Fixes #140. Corrects socket.io room reconnection and local state update on reactions toggle.