Package 

Class MessageListViewModel

    • Constructor Detail

      • MessageListViewModel

        MessageListViewModel(MessageListController messageListController, ChatClient chatClient)
        Parameters:
        messageListController - Controller used to relay the logic and fetch the state.
    • Method Detail

      • getChannelState

         final StateFlow<ChannelState> getChannelState()

        Holds information about the current channel and is actively updated.

      • getChannel

         final LiveData<Channel> getChannel()

        The current channel used to load the message list data.

      • getOwnCapabilities

         final LiveData<Set<String>> getOwnCapabilities()

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

        e.g. send messages, delete messages, etc... For a full list @see ChannelCapabilities.

      • getMode

         final LiveData<MessageMode> getMode()

        Whether the user is viewing a thread.

      • getTargetMessage

         final LiveData<Message> getTargetMessage()

        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.

      • getUnreadLabel

         final LiveData<MessageListController.UnreadLabel> getUnreadLabel()

        Emits the current unread label state.

      • getMessageById

         final Message getMessageById(String messageId)

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

        Parameters:
        messageId - The ID of the selected message.
      • scrollToBottom

         final Unit scrollToBottom(Integer messageLimit, Function0<Unit> scrollToBottom)

        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.

        Parameters:
        messageLimit - The limit of messages to load when loading newest messages.
        scrollToBottom - The handler that notifies when the data has been loaded to scroll to the bottom.
      • scrollToFirstUnreadMessage

         final Unit scrollToFirstUnreadMessage()

        Scrolls to the first unread message in the list. If there are no unread messages, this method does nothing.

        Important: It is possible that the first unread message is not loaded in the list yet. In this case, the method will first try to load that message, and then scroll to it.

      • hideUnreadSeparator

         final Unit hideUnreadSeparator()

        Hides the unread label in the messages list (if already visible).

      • setDateSeparatorHandler

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

        Parameters:
        dateSeparatorHandler - The handler to use.
      • setThreadDateSeparatorHandler

         final Unit setThreadDateSeparatorHandler(DateSeparatorHandler threadDateSeparatorHandler)

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

        Parameters:
        threadDateSeparatorHandler - The handler to use.
      • setMessagePositionHandler

         final Unit setMessagePositionHandler(MessagePositionHandler messagePositionHandler)

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

        Parameters:
        messagePositionHandler - The handler to use.
      • setMessageFooterVisibility

         final Unit setMessageFooterVisibility(MessageFooterVisibility messageFooterVisibility)

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

        Parameters:
        messageFooterVisibility - Determines the visibility of message footers.
      • setAreSystemMessagesVisible

         final Unit setAreSystemMessagesVisible(Boolean showSystemMessages)

        Sets whether the system messages should be visible.

        Parameters:
        showSystemMessages - Whether system messages should be visible or not.