Thread

The thread view is represented by the ChatThreadVC component. It is very similar with the ChatChannelVC, the difference is that instead of displaying messages, it displays the replies of a message thread. Just like the ChatChannelVC it also contains the ComposerVC component to create new replies.

The thread view consists of the following components:

  • ChatThreadHeaderView: responsible to display the thread information in the navigationItem.titleView.
  • ChatMessageListVC: responsible to render the replies of the thread.
  • ComposerVC: responsible to create new replies.

Basic Usage

By default, the ChatThreadVC is created when you click to see the replies of a message in the ChatMessageListVC component. But in case you want to create it programmatically, you can use the following code:

let cid = ChannelId(type: "messaging", id: "channel-id")
let messageId: MessageId = "message-id"
let threadVC = ChatThreadVC()
threadVC.channelController = ChatClient.shared.channelController(for: cid)
threadVC.messageController = ChatClient.shared.messageController(
    cid: cid,
    messageId: messageId
)

navigationController?.show(threadVC, sender: self)

UI Customization

You can customize how the thread view looks by subclassing it and swap the component in Components configuration:


Components.default.threadHeaderView = CustomChatThreadHeaderView.self
Components.default.threadVC = CustomChatThreadVC.self

Just like the ChatChannelVC, the ChatThreadVC is only responsible for composing the ChatThreadHeaderView, ChatMessageListVC and ComposerVC components together. In case you want to customize the rendering of the replies, you should read the Message documentation.