Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AND-296] Expose scrollToFirstUnreadMessage on MessageListViewModel. #5635

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

VelikovPetar
Copy link
Contributor

🎯 Goal

Exposes the scrollToFirstUnreadMessage method from the MessageListController on the MessageListViewModels.

Additionally, fixes a bug where the chatClient.loadMessagesAroundId wasn't called, when calling scrollToFirstUnreadMessage when the message wasn't already loaded.

🛠 Implementation details

  • Expose scrollToFirstUnreadMessage on MessageListViewModel(compose)
  • Expose scrollToFirstUnreadMessage on MessageListViewModel(xml)
  • Fix chatClient.loadMessagesAroundId not called:
messages.firstOrNull { it.id == unreadLabel.lastReadMessageId }
                ?.let { messages.focusUnreadMessage(it.id) }
                ?: {  // <- This was never called as it is lambda that wasn't invoked
                    scope.launch {
                        chatClient.loadMessagesAroundId(cid, unreadLabel.lastReadMessageId)
                            .await()
                            .onSuccess { channel -> channel.messages.focusUnreadMessage(unreadLabel.lastReadMessageId) }
                    }
                }

🎨 UI Changes

Demo for bugfix:

Before After
before.mp4
after.mp4

🧪 Testing

  1. Open XML sample app
  2. Ensure there is a conversation with an unread message which is not yet loaded (older than the 30th message)
  3. Tap on the "Unread messages" floating badge
  4. You should now be scrolled to the first unread message (after a brief delay while the messages are loaded)

Copy link
Contributor

github-actions bot commented Feb 14, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 3.17 MB 3.17 MB 0.00 MB 🟢
stream-chat-android-offline 3.38 MB 3.38 MB 0.00 MB 🟢
stream-chat-android-ui-components 7.87 MB 7.87 MB 0.00 MB 🟢
stream-chat-android-compose 8.75 MB 8.75 MB 0.00 MB 🟢

@VelikovPetar VelikovPetar marked this pull request as ready for review February 14, 2025 11:07
@VelikovPetar VelikovPetar requested a review from a team as a code owner February 14, 2025 11:07
@JcMinarro JcMinarro enabled auto-merge (squash) February 18, 2025 17:27
@JcMinarro JcMinarro force-pushed the feature/expose-scroll-to-first-unread branch from 4f3a704 to fe6e602 Compare February 18, 2025 17:28
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@JcMinarro JcMinarro merged commit 9255bea into develop Feb 18, 2025
9 of 13 checks passed
@JcMinarro JcMinarro deleted the feature/expose-scroll-to-first-unread branch February 18, 2025 20:07
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.

2 participants