Controller responsible for handling the composing and sending of messages.
It acts as a central place for both the core business logic and state required to create and send messages, handle attachments, message actions and more.
If you require more state and business logic, compose this Controller with your code and apply the necessary changes.
The ID of the channel we're chatting in.
The client used to communicate to the API.
The maximum number of attachments that can be sent in a single message.
Tne maximum file size of each attachment in bytes. By default, 100 MB for Stream CDN.
Holds information about the current state of the Channel.
Represents a Flow that holds the last active MessageAction that is either the Edit, Reply.
Current message mode, either MessageMode.Normal or MessageMode.MessageThread. Used to determine if we're sending a thread reply or a regular message.
Stores the selected attachments from the attachment picker. These will be shown in the UI, within the composer component. We upload and send these attachments once the user taps on the send button.
Builds a new Message to send to our API. If isInEditMode is true, we use the current action's message and apply the given changes.
Clears all the data from the input - both the current input value and the selectedAttachments.
Dismisses all message actions from the UI and clears the input if isInEditMode is true.
Dismisses the suggestions popup above the message composer.
Updates the UI state when leaving the thread, to switch back to the MessageMode.Normal, by calling setMessageMode.
Handles selected messageAction. We only have three actions we can react to in the composer:
Removes a selected attachment from the list, when the user taps on the cancel/delete button.
Switches the message composer to the command input mode.
Autocompletes the current text input with the mention from the selected user.
Sends a given message using our Stream API. Based on isInEditMode, we either edit an existing message, or we send a new message, using ChatClient. In case the message is a moderated message the old one is deleted before the replacing one is sent.
Called when the "Also send as a direct message" checkbox is checked or unchecked.
Called when the input changes and the internal state needs to be updated.
Called when the message mode changes and the internal state needs to be updated.
Toggles the visibility of the command suggestion list popup.