stream-chat-android icon indicating copy to clipboard operation
stream-chat-android copied to clipboard

scrollToSelectedMessage() not working if the message is not already fetched

Open mararzu opened this issue 3 years ago • 2 comments
trafficstars

Describe the bug Using MessageListViewModel.scrollToSelectedMessage(message: Message) is not working properly Let's say the chat room has 100 messages and we want to scroll to the message nro 10 (the nro 1 being the oldest message), if we enter the chat the message with nro 10 will not be fetched, so making a scrollToSelectedMessage() to it will make the bug occur. I'm missing some other way to scroll to a not fetched message ("old message")?

SDK version

  • 5.7.0

To Reproduce I'm using the Android Compose components Steps to reproduce the behavior:

  1. Go to a channel with more messages than the pagination (let's say the channel has 100 messages, the nro 1 being the oldest one)
  2. Without scrolling up or loading more messages than what is loaded by default, make a call to the MessageListViewModel.scrollToSelectedMessage(<"old message" object here>) with one of the first messages (or any that is not fetched already) Before 3. let's assume we scrolled to message nro 10, and that in order to fetch that message the SDK fetched the page with messages from nro 10 to nro 25
  3. The app will "scroll" to that message and for 0.3 seconds you will see that message, after that will scroll down to message nro 25 (the last one of the page that was fetched in order to get the message nro 10). So the actual message we wanted to scroll is no longer visible on the screen (the ones with id 25, 24, 23, 22, 21.. are)
  4. Another bug I think is that the pagination stops working, if you want to scroll either up or down to see other messages you can't, the component won't load more

Expected behavior

  1. If we use the scrollToSelectedMessage() method the component should take the user to that message and stay there
  2. If we use the scrollToSelectedMessage() method to a message that is not fetched the component should be able to keep the pagination working, so we can scroll up or down and start getting other messages

If this method is not intended for my use case, with which method or how could I achieve that? Looking into your code I realize that the tap on a "quoted" message (or reply) uses internally this method, that's why I think I'm spouse to use it too

Device:

  • Pixel 5
  • Android version: 12
  • User Compose components

mararzu avatar Aug 04 '22 19:08 mararzu

Hey @mararzu, thank you for reporting the issue. We are currently working on jumping to message improvements by implementing improved bi-directional pagination. We expect this to be released in one of the upcoming releases and we will let you know once the new implementation is ready to use.

adasiewiczr avatar Aug 05 '22 09:08 adasiewiczr

I don't know why I marked this as completed. Maybe I pressed some kind of shortcut that made the action or something like that. Sorry about that!

mararzu avatar Aug 08 '22 02:08 mararzu

This has been merged into develop for v6 release (upcoming major). We'll close the issue for now and then once it's out we can see if the issue persists.

filbabic avatar Oct 24 '22 06:10 filbabic