ChannelListViewModel

constructor(chatClient: ChatClient, initialSort: QuerySorter<Channel> = QuerySortByField.descByName("last_updated"), initialFilters: FilterObject? = null, channelLimit: Int = DEFAULT_CHANNEL_LIMIT, memberLimit: Int? = null, messageLimit: Int? = null, chatEventHandlerFactory: ChatEventHandlerFactory = ChatEventHandlerFactory(chatClient.clientState), searchDebounceMs: Long = SEARCH_DEBOUNCE_MS, draftMessagesEnabled: Boolean = true, messageSearchSort: QuerySorter<Message>? = null, globalState: Flow<GlobalState> = chatClient.globalStateFlow)

Creates a view model that queries channels by an explicit filter and sort.

Parameters

chatClient

The prepared ChatClient instance required for fetching the data.

initialSort

The initial sort used for Channels. Can be changed at runtime via setQuerySort.

initialFilters

The data filter. When null, a default filter scoped to "messaging" channels the current user is a member of is used. Can be changed at runtime via setFilters.

channelLimit

How many channels we fetch per page.

memberLimit

How many members are fetched for each channel item when loading channels. When null, the server-side default is used.

messageLimit

How many messages are fetched for each channel item when loading channels. When null, the server-side default is used.

chatEventHandlerFactory

The instance of ChatEventHandlerFactory used to create ChatEventHandler.

searchDebounceMs

The debounce time for search queries.

draftMessagesEnabled

If the draft message feature is enabled.

messageSearchSort

Sorting for message search results. When null, the server-side default is used.

globalState

A flow emitting the current GlobalState.


constructor(chatClient: ChatClient, predefinedFilterName: String, filterValues: Map<String, Any>? = null, sortValues: Map<String, Any>? = null, channelLimit: Int = DEFAULT_CHANNEL_LIMIT, memberLimit: Int? = null, messageLimit: Int? = null, chatEventHandlerFactory: ChatEventHandlerFactory = ChatEventHandlerFactory(chatClient.clientState), searchDebounceMs: Long = SEARCH_DEBOUNCE_MS, draftMessagesEnabled: Boolean = true, messageSearchSort: QuerySorter<Message>? = null, globalState: Flow<GlobalState> = chatClient.globalStateFlow)

Creates a view model that queries channels using a predefined filter resolved by the server.

The filter and sort are identified by predefinedFilterName and resolved server-side; filterValues and sortValues interpolate into the predefined template. setFilters and setQuerySort do not affect a view model created this way.

Parameters

chatClient

The prepared ChatClient instance required for fetching the data.

predefinedFilterName

The name of the predefined filter registered on the backend.

filterValues

Optional values interpolated into the predefined filter template.

sortValues

Optional values interpolated into the predefined sort template.

channelLimit

How many channels we fetch per page.

memberLimit

How many members are fetched for each channel item when loading channels. When null, the server-side default is used.

messageLimit

How many messages are fetched for each channel item when loading channels. When null, the server-side default is used.

chatEventHandlerFactory

The instance of ChatEventHandlerFactory used to create ChatEventHandler.

searchDebounceMs

The debounce time for search queries.

draftMessagesEnabled

If the draft message feature is enabled.

messageSearchSort

Sorting for message search results. When null, the server-side default is used.

globalState

A flow emitting the current GlobalState.


constructor(groupKey: String, chatClient: ChatClient = ChatClient.instance(), searchDebounceMs: Long = SEARCH_DEBOUNCE_MS, draftMessagesEnabled: Boolean = true, messageSearchSort: QuerySorter<Message>? = null, globalState: Flow<GlobalState> = chatClient.globalStateFlow)

Grouped channel list constructor. Subscribes to the state identified by groupKey without issuing a remote call; the state is populated externally by queryGroupedChannels responses.

IMPORTANT: This is an enterprise feature and is disabled by default. For more info, reach out to our Contact & Support.

Parameters

groupKey

The name of the channels group.

chatClient

The prepared ChatClient instance required for fetching the data.

searchDebounceMs

The debounce time for search queries.

draftMessagesEnabled

If the draft message feature is enabled.

messageSearchSort

Sorting for message search results. When null, the server-side default is used.

globalState

A flow emitting the current GlobalState.