MessageComposerController
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.
Parameters
The CID of the channel we're chatting in.
The client used to communicate to the API.
The current state of the channel.
The media recorder used to record audio messages.
The handler used to lookup users for mentions.
The function used to convert a file to a URI.
The maximum number of attachments that can be sent in a single message.
If the link preview is enabled in the channel.
Constructors
Properties
If the message will be shown in the channel after it is sent.
Represents the list of commands that can be executed for the channel.
Represents the remaining time until the user is allowed to send the next message.
Represents a Flow that holds the last active MessageAction that is either the Edit, Reply.
Represents the list of links that can be previewed.
Represents the list of users that can be used to autocomplete the current mention input.
Set of currently active message actions. These are used to display different UI in the composer, as well as help us decorate the message with information, such as the quoted message id.
UI state of the current composer input.
Current message mode, either MessageMode.Normal or MessageMode.MessageThread. Used to determine if we're sending a thread reply or a regular message.
Holds information about the abilities the current user is able to exercise in the given channel.
Represents the currently selected attachments, that are shown within the composer UI.
Full message composer state holding all the required information.
Buffers typing updates.
Represents the list of validation errors for the current text input and the currently selected attachments.
Functions
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.
Cancels audio recording and moves MessageComposerState.recording state to RecordingState.Idle.
Clears all the data from the input - both the current input value and the selectedAttachments.
Completes audio recording and moves MessageComposerState.recording state to RecordingState.Complete. Also, it wil update MessageComposerState.attachments list.
Creates a poll with the given pollConfig.
Dismisses all message actions from the UI and clears the input if isInEditMode is true.
Dismisses the suggestions popup above the message composer.
Sends coordinates of the touch event to the AudioRecordingController.
Updates the UI state when leaving the thread, to switch back to the MessageMode.Normal, by calling setMessageMode.
Moves MessageComposerState.recording state to RecordingState.Locked.
Pauses audio recording and sets RecordingState.Overview.isPlaying to false.
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.
Pauses audio recording and seeks to the given progress. Sets RecordingState.Overview.isPlaying to false. Sets RecordingState.Overview.playingProgress to the given progress.
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.
Starts audio recording and moves MessageComposerState.recording state from RecordingState.Idle to RecordingState.Hold.
Stops audio recording and moves MessageComposerState.recording state to RecordingState.Overview.
Toggles the visibility of the command suggestion list popup.
Toggles audio recording playback if MessageComposerState.recording is instance of RecordingState.Overview.