Messenger Starter - Kris - #4
Open
k-milan wants to merge 8 commits into
Open
Conversation
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.
Description
Implemented fixes and improvements for message handling in the chat app.
Changes include:
Fixed optimistic updates when sending messages in new and existing conversations.
Fixed message ordering so chat messages display in the expected order.
Added conversation-level read tracking using user1LastReadMessageId and user2LastReadMessageId.
Added read receipt UI by showing the other user’s avatar under the last message they have read.
Added backend support for marking a conversation as read.
Added notes for webhook ingestion architecture in architecture.md.
Notes on your approach and thought process
For the message rendering bug, I found that the frontend was mutating the existing conversations state directly with forEach and then passing the same array reference back into state. React may not detect that as a meaningful state change, so I changed the updates to use immutable state updates with setConversations.
For read receipts, I considered message-level read fields first, but chose a conversation-level read pointer because the UI only needs to know the latest message each user has read. This avoids updating multiple message rows and makes the frontend check straightforward.
I also made sure read receipts are only triggered when the user actually opens a conversation or is actively viewing the conversation when a new message arrives.