2

Im using getStream ChatChannelListView to present all channels. But when there is no chats im overriding ViewFactory makeNoChannelsView with my custom noChannelsView that has button to initiate chat.

As my noChannelsView is embeded in NavigationView its destination is ChatChannel but as soon as I try to fetchOneChannel and open it, noChatsView starts transition to ChatChannel and at the middle of that transition whole noChannelsView is being replaced with ChatChannelListView and then I need to mannualy enter my chosen channel.

Nikola
  • 65
  • 5

1 Answers1

2

For a use-case like this you can use the ChatChannelListView and aside from your custom ViewFactory also hand it a selectedChannelId in form of a String.

Code looks like this:

var body: some View {
    ChatChannelListView(
        viewFactory: MyViewFactory(),
        selectedChannelId: "channel-id"
    )
}

In order to make this dynamic, you can use a @Binding for the selectedChannelId and update this once the channel is created in order to directly show the Channel UI.

Let me know if you still have questions, we are also recommending this technique for deep linking as you can see in our documentation.

Best, Stefan

Stefan Blos
  • 172
  • 7
  • Thanks for the fast answer @Stefan do you have any working example maybe? In most recent tutorial it was explained how to add floating button above TabBar that should have that funcionality to initiate chat but that was not part of turorial so its missing. – Nikola Sep 07 '22 at 17:37