You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The channel list item was displaying channel.lastMessageAt as the timestamp, which can differ from the actual shown message's createdAt time (ex. when the last message is deleted). This caused incorrect timestamps to be shown next to channel items.
This PR fixes the timestamp display by using the last message's createdAt property directly, instead of Channel.lastMessageAt
XML UI (ChannelViewHolder.kt): Changed ChatUI.dateFormatter.formatDate(channel.lastMessageAt) to ChatUI.dateFormatter.formatDate(lastMessage.getCreatedAtOrNull())
Both the Compose and XML-based UI components now use the same source of truth for the timestamp.
🎨 UI Changes
before.mp4after.mp4
Testing
Open the channel list
Open a channel
Delete the last message
Exit the channel
Verify the timestamp matches the shown message in the channel item
Both channel list UI components now derive the last message timestamp from the lastMessage's createdAt property instead of the channel's lastMessageAt property, ensuring timestamp consistency with the actual message creation date.
Replaced channel.lastMessageAt with lastMessage.getCreatedAtOrNull() for rendering the last message timestamp, sourcing the timestamp directly from the message object rather than the channel metadata. Added import for getCreatedAtOrNull utility function.
Suggested reviewers
gpunto
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
🐰 Whiskers twitch with delight, Timestamps dance in the light, From message they spring, No channel strings, Truth flows where creation shines bright! ✨
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title clearly and concisely summarizes the main change: fixing incorrect timestamps displayed on channel list items.
Description check
✅ Passed
The description covers the required template sections well: Goal explains the problem, Implementation details the changes in both Compose and XML UIs, Testing provides clear steps, and most critical checklist items are addressed.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch bug/AND-1044_fix_wrong_timestamp_on_channel_item
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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
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.
Goal
The channel list item was displaying
channel.lastMessageAtas the timestamp, which can differ from the actual shown message'screatedAttime (ex. when the last message is deleted). This caused incorrect timestamps to be shown next to channel items.This PR fixes the timestamp display by using the last message's
createdAtproperty directly, instead ofChannel.lastMessageAtImplementation
ChannelItem.kt): ChangedTimestamp(date = channel.lastMessageAt)toTimestamp(date = lastMessage.getCreatedAtOrNull())ChannelViewHolder.kt): ChangedChatUI.dateFormatter.formatDate(channel.lastMessageAt)toChatUI.dateFormatter.formatDate(lastMessage.getCreatedAtOrNull())Both the Compose and XML-based UI components now use the same source of truth for the timestamp.
🎨 UI Changes
before.mp4
after.mp4
Testing
☑️Contributor Checklist
General
developbranchCode & documentation
🎉 GIF
Summary by CodeRabbit