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

Add ability to change filter on ChannelList in the state layer #3527

Closed
vojtabohm opened this issue Dec 3, 2024 · 2 comments
Closed

Add ability to change filter on ChannelList in the state layer #3527

vojtabohm opened this issue Dec 3, 2024 · 2 comments

Comments

@vojtabohm
Copy link

vojtabohm commented Dec 3, 2024

What are you trying to achieve?

I want to display a channel list with some filtering options:
Simulator - 2024-12-03 at 15 33 44@2x

Searching, filtering unreads and group chats.

If possible, how can you achieve this currently?

I need to create a ChatChannelListController and use synchronize and delegates, wrap it in a viewmodel and expose it to my custom SwiftUI view using @Published. Which is not ideal given that StreamChat provides a state layer promising async/await and observation.

What would be the better way?

ChannelList in the state layer should have some method like updateFilter that would refresh the query, the same way ChatChannelListController does it. So we could use modern async/await + @Published and re-render views automatically when filtering changes.

I tried to create a wrapper viewmodel class that would just create queries and channels based on filter and then just call .get() whenever the filter changes. But that stops realtime updates for some reason.

GetStream Environment

GetStream Chat version: 4.67.0
GetStream Chat frameworks:
iOS version: 18.0
Swift version: 5.9
Xcode version: 15.1
Device: iPhone 16 Simulator

Additional context

Maybe I am doing something wrong but I don't know how to approach this using ChannelList

@laevandus laevandus transferred this issue from GetStream/stream-chat-swiftui Dec 9, 2024
@laevandus
Copy link
Contributor

Hi @vojtabohm, I'll make an internal note about this request.
But for now, I have created a simple example how it would be possible to use ChannelList type in a view model for search. Please check this gist.

But if you need additional help with this, please reach out to use using our engineering support. That is the best way to get code-level help.

Thank you
Toomas

@vojtabohm
Copy link
Author

Thanks for the gist @laevandus . I actually implemented it very similarly in the end. I was just not sure if it was okay to make a channel list for each search query as the user types. I thought it was wasteful.

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

No branches or pull requests

2 participants