MessageListViewModel

class MessageListViewModel(messageListController: MessageListController, chatClient: ChatClient = ChatClient.instance()) : ViewModel

View model class for MessageListView. Responsible for updating the list of messages. Can be bound to the view using MessageListViewModel.bindView function.

Parameters

messageListController

Controller used to relay the logic and fetch the state.

Constructors

Link copied to clipboard
constructor(messageListController: MessageListController, chatClient: ChatClient = ChatClient.instance())

Types

Link copied to clipboard
sealed class Event

Represents events coming from the View class.

Link copied to clipboard
sealed class State

The current state of the message list.

Properties

Link copied to clipboard

The current channel used to load the message list data.

Link copied to clipboard
val channelState: StateFlow<ChannelState?>

Holds information about the current channel and is actively updated.

Link copied to clipboard

Regulates the visibility of deleted messages.

Link copied to clipboard
Link copied to clipboard

Emits the status of searching situation. True when inside a search and false otherwise.

Link copied to clipboard

Emits true if we should are loading more older messages.

Link copied to clipboard

Regulates the message footer visibility.

Link copied to clipboard

Whether the user is viewing a thread.

Link copied to clipboard

Holds information about the abilities the current user is able to exercise in the given channel.

Link copied to clipboard

Determines whether we should show system messages or not.

Link copied to clipboard

Current message list state.

Link copied to clipboard

The target message that the list should scroll to. Used when scrolling to a pinned message, a message opened from a push notification or similar.

Link copied to clipboard

Unread count of the channel or thread depending on MessageMode.

Link copied to clipboard

Emits the current unread label state.

Link copied to clipboard

The currently logged in user.

Functions

Link copied to clipboard
fun getMessageById(messageId: String): Message?

Returns a message with the given ID from the messages list.

Link copied to clipboard

Handles an Event coming from the View layer.

Link copied to clipboard
fun scrollToBottom(messageLimit: Int = messageListController.messageLimit, scrollToBottom: () -> Unit)

When the user clicks the scroll to bottom button we need to take the user to the bottom of the newest messages. If the messages are not loaded we need to load them first and then scroll to the bottom of the list.

Link copied to clipboard
fun setAreSystemMessagesVisible(showSystemMessages: Boolean)

Sets whether the system messages should be visible.

Link copied to clipboard
fun setDateSeparatorHandler(dateSeparatorHandler: DateSeparatorHandler?)

Sets the date separator handler which determines when to add date separators. By default, a date separator will be added if the difference between two messages' dates is greater than 4h.

Link copied to clipboard

Sets the value used to filter deleted messages.

Link copied to clipboard

Sets the value used to determine if message footer content is shown.

Link copied to clipboard

Sets a handler which determines the position of a message inside a group.

Link copied to clipboard
fun setThreadDateSeparatorHandler(threadDateSeparatorHandler: DateSeparatorHandler?)

Sets thread date separator handler which determines when to add date separators inside the thread.

Inherited functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
@JvmName(name = "bind")
fun MessageListViewModel.bindView(view: MessageListView, lifecycleOwner: LifecycleOwner)

Binds MessageListView with MessageListViewModel, updating the view's state based on data provided by the ViewModel, and forwarding View events to the ViewModel.

Link copied to clipboard