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

Reset channel list in calls to ChannelService.init()?

Open nvahalik opened this issue 2 years ago • 4 comments

Hello!

We have a weird issue that seems to relate to the various calls of init() and reset() on the ChannelService.

In short, we have a configuration service that is responsible for setting the standard "filter list" that gets passed to init(). We call reset() and then init(). The issue is that sometimes due to a configuration change on the user, the filters will update. If we are on a user's chat page, it will always deselect the active chat, which can cause chats to simply disappear.

IMO, it would be a better overall DX if the channel listing was always reset when calling init(). As it stands, you either must always call reset(), which will deselect the chat, even if you don't want it to, or you will get duplicate records in the channels$ observable.

nvahalik avatar May 11 '23 21:05 nvahalik

Hi!

Your points make sense to me:

  • init() should clean the old channel list
  • init() shouldn't deselect the previous active channel if the channel is present in the new channel list

I've added this to the backlog, you'll be notified through this GH issue when this is resolved.

szuperaz avatar May 12 '23 07:05 szuperaz

Hello, do we have any news about this issue? 😁

duartejonathan avatar Aug 07 '23 21:08 duartejonathan

I will try to get this done by the end of August, but I might not be able to do so.

szuperaz avatar Aug 08 '23 12:08 szuperaz

An update on this: unfortunately, this won't be part of our August release, no ETA for now.

As a workaround, you can do this when you want to change the filters:

  • Call init with shouldSetActiveChannel option set to false
  • Once init is done, and the previous active channel is still in the list, you can manually select it again with channelService.setAsActiveChannel

This doesn't solve the problem completely, as the active channel will change like this: <channel> -> undefined -> <channel>, so it'll still be undefined for a short amount of time.

szuperaz avatar Aug 15 '23 14:08 szuperaz