Package 

Class ChannelListViewModel

    • Constructor Detail

      • ChannelListViewModel

        ChannelListViewModel(ChatClient chatClient, QuerySorter<Channel> initialSort, FilterObject initialFilters, Integer channelLimit, Integer memberLimit, Integer messageLimit, ChatEventHandlerFactory chatEventHandlerFactory, Long searchDebounceMs, Boolean isDraftMessageEnabled, QuerySorter<Message> messageSearchSort, Flow<GlobalState> globalState)
        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.
        initialFilters - The data filter.
        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.
        searchDebounceMs - The debounce time for search queries.
        isDraftMessageEnabled - If the draft message feature is enabled.
        messageSearchSort - Sorting for message search results.
        globalState - A flow emitting the current GlobalState.
      • ChannelListViewModel

        ChannelListViewModel(ChatClient chatClient, String predefinedFilterName, Map<String, Object> filterValues, Map<String, Object> sortValues, Integer channelLimit, Integer memberLimit, Integer messageLimit, ChatEventHandlerFactory chatEventHandlerFactory, Long searchDebounceMs, Boolean isDraftMessageEnabled, QuerySorter<Message> messageSearchSort, Flow<GlobalState> globalState)
        Creates a view model that queries channels using a predefined filter resolved by the server.
        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.
        messageLimit - How many messages are fetched for each channel item when loading channels.
        chatEventHandlerFactory - The instance of ChatEventHandlerFactory used to create ChatEventHandler.
        searchDebounceMs - The debounce time for search queries.
        isDraftMessageEnabled - If the draft message feature is enabled.
        messageSearchSort - Sorting for message search results.
        globalState - A flow emitting the current GlobalState.
      • ChannelListViewModel

        ChannelListViewModel(ChatClient chatClient, String groupKey, Long searchDebounceMs, Boolean isDraftMessageEnabled, QuerySorter<Message> messageSearchSort, Flow<GlobalState> globalState)
        Grouped channel list constructor.
        Parameters:
        chatClient - The prepared ChatClient instance required for fetching the data.
        groupKey - The name of the channels group.
        searchDebounceMs - The debounce time for search queries.
        isDraftMessageEnabled - If the draft message feature is enabled.
        messageSearchSort - Sorting for message search results.
        globalState - A flow emitting the current GlobalState.
    • Method Detail

      • getChannelsState

         final ChannelsState getChannelsState()

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

      • getSelectedChannel

         final MutableState<Channel> getSelectedChannel()

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

      • getActiveChannelAction

         final ChannelAction getActiveChannelAction()

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

      • getConnectionState

         final StateFlow<ConnectionState> getConnectionState()

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

      • getUser

         final StateFlow<User> getUser()

        The state of the currently logged in user.

      • getChannelMutes

         final StateFlow<List<ChannelMute>> getChannelMutes()

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

      • isChannelMuted

         final Boolean isChannelMuted(String cid)

        Checks if the channel is muted for the current user.

        Parameters:
        cid - The CID of the channel that needs to be checked.
      • refresh

         final Unit refresh()

        Refreshes either channels or search results.

      • selectChannel

         final Unit selectChannel(Channel channel)

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

      • setSearchQuery

        @Deprecated(message = Use setSearchQuery instead, replaceWith = @ReplaceWith(imports = {io.getstream.chat.android.compose.state.channels.list.SearchQuery}, expression = setSearchQuery(SearchQuery.Channels(newQuery)))) final Unit setSearchQuery(String newQuery)

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

        The new operation will hold the channels that match the new query.

      • setFilters

         final Unit setFilters(FilterObject newFilters)

        Allows for the change of filters used for channel queries.

        Use this if you need to support runtime filter changes, through custom filters UI. The applied filter overrides the initialFilters set through the constructor.

        Warning: The filter that's applied will override the initialFilters set through the constructor. Has no effect on view models constructed for a predefined-filter query (predefined identity is fixed at construction) or for a grouped query (the group's filter is server-owned).

        Parameters:
        newFilters - The new filters to be used as a baseline for filtering channels.
      • setQuerySort

         final Unit setQuerySort(QuerySorter<Channel> querySort)

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

        Use this if you need to support runtime sort changes, through custom sort UI.

        Has no effect on view models constructed for a predefined-filter query (sort is resolved by the server) or for a grouped query (the group's sort is fixed).

      • loadMore

         final Unit loadMore()

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

      • performChannelAction

         final Unit performChannelAction(ChannelAction channelAction)

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

        It also removes the selectedChannel if the action is Cancel.

        Parameters:
        channelAction - The selected action.
      • muteChannel

         final Unit muteChannel(Channel channel)

        Mutes a channel.

        Parameters:
        channel - The channel to mute.
      • pinChannel

         final Unit pinChannel(Channel channel)

        Pins a channel.

        Parameters:
        channel - The channel to pin.
      • unpinChannel

         final Unit unpinChannel(Channel channel)

        Unpins a channel.

        Parameters:
        channel - The channel to unpin.
      • unmuteChannel

         final Unit unmuteChannel(Channel channel)

        Unmutes a channel.

        Parameters:
        channel - The channel to unmute.
      • deleteConversation

         final Unit deleteConversation(Channel channel)

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

        Parameters:
        channel - The channel to delete.
      • leaveGroup

         final Unit 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.

        Parameters:
        channel - The channel to leave.