Skip to content

fix: message reactions syncing across devices#186

Open
adityashirsatrao007 wants to merge 10 commits into
chthonn:mainfrom
adityashirsatrao007:fix/reactions-sync
Open

fix: message reactions syncing across devices#186
adityashirsatrao007 wants to merge 10 commits into
chthonn:mainfrom
adityashirsatrao007:fix/reactions-sync

Conversation

@adityashirsatrao007

Copy link
Copy Markdown

Fixes #140. Corrects socket.io room reconnection and local state update on reactions toggle.

Copilot AI review requested due to automatic review settings May 30, 2026 10:23
@vercel

vercel Bot commented May 30, 2026

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_reaction and toggle_dm_reaction endpoints plus schema additions for reactions arrays.
  • Frontend UI (emoji picker + reaction chips) and socket listeners (reaction_updated, dm_reaction_updated) in ValidChat.jsx and DirectMessage.jsx.
  • Re-emit join_*/get_userid on socket connect to 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 thread server/src/routes/chat.js
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 thread server/src/routes/chat.js
Comment on lines +347 to +350
} catch (err) {
res.status(500).json({ status: 500 });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Message reactions not syncing across devices

3 participants