Skip to content

feat: centralize realtime message reconciliation#240

Open
ash1shkumar wants to merge 1 commit into
Shriii19:masterfrom
ash1shkumar:realtime-message-reconciliation
Open

feat: centralize realtime message reconciliation#240
ash1shkumar wants to merge 1 commit into
Shriii19:masterfrom
ash1shkumar:realtime-message-reconciliation

Conversation

@ash1shkumar
Copy link
Copy Markdown
Contributor

@ash1shkumar ash1shkumar commented Jun 5, 2026

Description

Summary

This PR improves the realtime messaging architecture by consolidating socket-driven state reconciliation into reusable helper functions. Previously, multiple socket event handlers performed independent state update operations, resulting in duplicated reconciliation logic and increased maintenance complexity.

Changes Made

  • Added reusable message reconciliation helpers:

    • reconcileIncomingMessage
    • reconcileSeenStatus
    • reconcileReactionUpdate
    • shouldUpdateOnlineUsers
  • Refactored newMessage event handling to use centralized reconciliation logic.

  • Refactored messageSeen event handling to use a shared status reconciliation helper.

  • Refactored reactionUpdate event handling to use a reusable reaction reconciliation workflow.

  • Refactored onlineUsers event handling to use centralized update comparison logic.

Benefits

  • Reduces duplicated state reconciliation logic.
  • Improves consistency across realtime event handlers.
  • Simplifies future maintenance and feature additions.
  • Reduces the likelihood of state drift during concurrent updates.
  • Provides a cleaner foundation for scaling realtime collaboration features.

Testing

  • Verified new messages are received correctly.
  • Verified unread message count behavior remains unchanged.
  • Verified message seen status updates correctly.
  • Verified reaction updates continue to synchronize properly.
  • Verified online user updates function as expected.
  • Confirmed no regressions in existing chat functionality.

Fixes #203

Expected Labels

level3 NSoC'26

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

@ash1shkumar is attempting to deploy a commit to the shreemp194-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 Thank you for opening this pull request! I will review your changes and assist you soon.

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.

Optimize Realtime Socket Event Reconciliation

1 participant