GetStream / stream-chat-flutter

Flutter Chat SDK - Build your own chat app experience using Dart, Flutter and the Stream Chat Messaging API.
https://getstream.io/chat/sdk/flutter/
Other
935 stars 343 forks source link

Updated Channel not reflected at top #777

Closed hiashutoshsingh closed 2 years ago

hiashutoshsingh commented 3 years ago

Which packages are you using?

stream_chat_flutter_core, stream_chat_persistance

On what platforms did you experience the issue?

iOS, Android

What version are you using?

stream_chat_flutter_core: 3.1.1 stream_chat_persistence: 3.0.0

What happened?

We are using ChannelsBloc and ChannelListCore with a limit of 10.

Suppose a condition in which there are 50 channels on the server and we are opening and watching a channel (by using channeId) that is not fetched yet through pagination and if we send a message into that channel and go back to inbox screen then updated channel is not at the top or in the that 10 fetched channels, however, if we fetch all channels through pagination and then send a message, then that channel will be shown at the top of the list.

Steps to reproduce

1. Fetch channels as per limit(10)
2. Watch a channel that is not in the 10 fetched channels list
3. Send a message into that channel
4. Observer that channel list again

Supporting info to reproduce

No response

Relevant log output

No response

Flutter analyze output

No response

Flutter doctor output

No response

Code of Conduct

xsahil03x commented 2 years ago

Hey @hiashutoshsingh,

In case the channel is not already present in the list you need also need to pass the shouldAddChannel function.

ChannelsBloc(
     shouldAddChannel: (event) => true,
     child: ChannelListCore(
                ...
            ),
       );

if this doesn't work, make sure you are creating your channel using client.channel().

Thanks, Sahil