Important feature request

Hi, guys!
I suggest you a change which will likely improve your ChannelListFragment behaviour.
I don’t understand why ChannelListViewModel is fragment scoped?
It can be activity scoped as you do inside ChannelFragment

I suggest following:

viewModel = new ViewModelProvider(getActivity(), new ViewModelFactory()).get(ChannelListViewModel.class);

Instead of this inside ChannelListFragment, method initChannelList()


Hi, @Vladislav_Karpman

Thank you for your suggestion! Do you have any trouble because ChannelListViewModel’s owner is a fragment instance?

Yes, because you all the time load everything + I would like to use it in another fragment in order to observe unread channels count.

1 Like

I understood all time load. However, I didn’t understand what the issue is when observing unread channel counts.

Imaging I need to show unread message count in other place of app.
How would you implement it?
And it should be always up to date

If you want to retrieve all channels total unread count, you can refer to our sample implementation.
If you want to retrieve unread count of the specific channel, you can retrieve channel instance and observe event by our Chat SDK.

I am not sure what you want to do.
Plus, Why getActivity() can resolve observing unread count? If view model is all the time load, unread count is also all the time load.

This topic is no longer relevant. Thanks

@Vladislav_Karpman We changed our logic for a single activity. ViewModels that fragments use are owned by fragment ViewModelStore. Please update v2.2.3! Thank you!