Closed srgray closed 1 month ago
Hi @srgray,
You will need to create a new controller and use replaceQuery()
or replaceChannelListController()
to refresh the data in this scenario.
Thank you, Nuno
@nuno-vieira That works great, thank you. Does ChatChannelVC
have a way to refresh the data after the user changes? Or do I need to recreate it?
@srgray You don't need to recreate the view, you only need to recreate the controller and refresh the data 👍
@nuno-vieira Can you take a look at this modified sample project? I'm recreating the controller for ChatChannelVC, but I don't know how to refresh the data: StreamSwitchUsers 3.zip
Steps:
Hi @srgray, as this is more of a customisation question than an SDK issue, it is best to reach out to our support. Feel free to share the link to this ticket so the support team has more context.
Thanks!
Best, Alex
Hi @srgray,
When you set the new controller than you need to call synchornize. Something like this:
channelController.delegate = self
channelController.synchronize { [weak self] error in
self?.didFinishSynchronizing(with: error)
}
@nuno-vieira thank you, that works!
What did you do?
I switched Stream users while a Stream view (
ChatChannelListVC
) was visible (and didn't recreate it).What did you expect to happen?
I expected Stream to refresh
ChatChannelListVC
with the new data after the other user was logged in.What happened instead?
ChatChannelListVC
shows empty data after disconnect/connect sequence.GetStream Environment
GetStream Chat version: 4.63.0 GetStream Chat frameworks: StreamChat, StreamChatUI iOS version: 18.0 Swift version: 5 Xcode version: 16 Device: iPhone 16 Pro simulator
Additional context
See attached sample project: StreamSwitchUsers 2.zip
Steps to reproduce:
How can I tell
ChatChannelListVC
to refresh after a new user is connected? I know that I can change my app navigation to recreate theChatChannelListVC
after the new user is connected, but I would like to know if I can avoid that. This goes for other Stream views likeChatChannelVC
, too.