ChannelListViewModel

class ChannelListViewModel(val chatClient: ChatClient, initialSort: QuerySorter<Channel>, initialFilters: FilterObject?, channelLimit: Int = DEFAULT_CHANNEL_LIMIT, memberLimit: Int = DEFAULT_MEMBER_LIMIT, messageLimit: Int = DEFAULT_MESSAGE_LIMIT, chatEventHandlerFactory: ChatEventHandlerFactory = ChatEventHandlerFactory(chatClient.clientState)) : ViewModel

A state store that represents all the information required to query, filter, show and react to Channel items in a list.

Parameters

chatClient

Used to connect to the API.

initialSort

The initial sort used for Channels.

initialFilters

The current data filter. Users can change this state using setFilters to impact which data is shown on the UI.

channelLimit

How many channels we fetch per page.

memberLimit

How many members are fetched for each channel item when loading channels.

messageLimit

How many messages are fetched for each channel item when loading channels.

chatEventHandlerFactory

The instance of ChatEventHandlerFactory used to create ChatEventHandler.

Constructors

Link copied to clipboard
constructor(chatClient: ChatClient, initialSort: QuerySorter<Channel>, initialFilters: FilterObject?, channelLimit: Int = DEFAULT_CHANNEL_LIMIT, memberLimit: Int = DEFAULT_MEMBER_LIMIT, messageLimit: Int = DEFAULT_MESSAGE_LIMIT, chatEventHandlerFactory: ChatEventHandlerFactory = ChatEventHandlerFactory(chatClient.clientState))

Properties

Link copied to clipboard

Currently active channel action, if any. Used to show a dialog for deleting or leaving a channel/conversation.

Link copied to clipboard
val channelMutes: StateFlow<List<ChannelMute>>

Gives us the information about the list of channels mutes by the current user.

Link copied to clipboard

The current state of the channels screen. It holds all the information required to render the UI.

Link copied to clipboard
Link copied to clipboard

The state of our network connection - if we're online, connecting or offline.

Link copied to clipboard

Currently selected channel, if any. Used to show the bottom drawer information when long tapping on a list item.

Link copied to clipboard
val user: StateFlow<User?>

The state of the currently logged in user.

Functions

Link copied to clipboard

Deletes a channel, after the user chooses the delete ChannelAction. It also removes the activeChannelAction, to remove the dialog from the UI.

Link copied to clipboard

Dismisses the activeChannelAction and removes it from the UI.

Link copied to clipboard

Checks if the channel is muted for the current user.

Link copied to clipboard
fun leaveGroup(channel: Channel)

Leaves a channel, after the user chooses the leave ChannelAction. It also removes the activeChannelAction, to remove the dialog from the UI.

Link copied to clipboard
fun loadMore()

Loads more data when the user reaches the end of the channels list.

Link copied to clipboard
fun muteChannel(channel: Channel)

Mutes a channel.

Link copied to clipboard

Clears the active action if we've chosen Cancel, otherwise, stores the selected action as the currently active action, in activeChannelAction.

Link copied to clipboard
fun selectChannel(channel: Channel?)

Changes the currently selected channel state. This updates the UI state and allows us to observe the state change.

Link copied to clipboard
fun setFilters(newFilters: FilterObject)

Allows for the change of filters used for channel queries.

Link copied to clipboard

Allows for the change of the query sort used for channel queries.

Link copied to clipboard
fun setSearchQuery(searchQuery: SearchQuery)

fun setSearchQuery(newQuery: String)

Changes the current query state. This updates the data flow and triggers another query operation.

Link copied to clipboard
fun unmuteChannel(channel: Channel)

Unmutes a channel.

Inherited functions

Link copied to clipboard