ChannelViewModel

class ChannelViewModel(repository: ChannelScreenResourceRepository, savedStateHandle: SavedStateHandle) : ViewModel, ChannelViewModelContract

ViewModel class for ChannelScreen.

Since

1.0.0

Constructors

Link copied to clipboard
constructor(repository: ChannelScreenResourceRepository, savedStateHandle: SavedStateHandle)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The StateFlow for the deleteMessage request.

Link copied to clipboard
open override val hasNext: Boolean

The flag to check if there is a next page. Refer to ChannelScreenResourceRepository.hasNext.

Link copied to clipboard
open override val hasPrevious: Boolean

The flag to check if there is a previous page. Refer to ChannelScreenResourceRepository.hasPrevious.

Link copied to clipboard
open override val initialized: StateFlow<Boolean>

The flag to check if the channel is initialized.

Link copied to clipboard
open override val loadNextEventState: StateFlow<SimpleSendbirdEventState>

The StateFlow for the loadNext request.

Link copied to clipboard
open override val loadPreviousEventState: StateFlow<SimpleSendbirdEventState>

The StateFlow for the loadPrevious request.

Link copied to clipboard
open override val messagesEventState: StateFlow<MessagesEvent>

The StateFlow of the MessagesEvent.

Link copied to clipboard

The StateFlow for the resendMessage request.

Link copied to clipboard

The StateFlow for the sendFileMessage request.

Link copied to clipboard

The StateFlow for the sendUserMessage request.

Link copied to clipboard
open override val totalMessagesState: StateFlow<List<UikitBaseMessage>>

The StateFlow of the list of UikitBaseMessage to display.

Link copied to clipboard
open override val uiState: StateFlow<SendbirdScreenUiState>

The StateFlow of the SendbirdScreenUiState.

Link copied to clipboard

The StateFlow for the updateUserMessage request.

Functions

Link copied to clipboard
open override fun deleteMessage(message: UikitBaseMessage)

Deletes a message with a given message. Deleting is only allowed for a message with ChatBaseMessage type.

Link copied to clipboard
open override fun loadInitial(startingPoint: Long)

Loads the initial messages.

Link copied to clipboard
open override fun loadNext()

Loads the messages to the latest direction to fetch newer messages.

Link copied to clipboard
open override fun loadPrevious()

Loads the messages to the previous direction to fetch older messages.

Link copied to clipboard

Notifies that the deleteMessage event has been processed to reset deleteMessageEventState to SendbirdEventState.Idle state.

Link copied to clipboard
open override fun notifyLoadNextEventProcessed()

Notifies that the loadNext event has been processed to reset loadNextEventState to SendbirdEventState.Idle state.

Link copied to clipboard

Notifies that the loadPrevious event has been processed to reset loadPreviousEventState to SendbirdEventState.Idle state.

Link copied to clipboard

Notifies that the resendMessage event has been processed to reset resendMessageEventState to SendbirdEventState.Idle state.

Link copied to clipboard

Notifies that the sendFileMessage event has been processed to reset sendFileMessageEventState to SendbirdEventState.Idle state.

Link copied to clipboard

Notifies that the sendUserMessage event has been processed to reset sendUserMessageEventState to SendbirdEventState.Idle state.

Link copied to clipboard

Notifies that the updateUserMessage event has been processed to reset updateUserMessageEventState to SendbirdEventState.Idle state.

Link copied to clipboard
@VisibleForTesting(otherwise = 4)
open override fun onCleared()
Link copied to clipboard
open override fun prepare()

The preparation process required for the screen. This contains the Chat SDK's connection by SendbirdChat.connect and getting the channel object ready if necessary.

Link copied to clipboard
open override fun resendMessage(message: UikitBaseMessage)

Resends a message with a given message. Resending is only allowed for a message with ChatBaseMessage type.

Link copied to clipboard
open override fun sendFileMessage(file: File)

Sends a file message with a given file.

Link copied to clipboard
open override fun sendUserMessage(message: String)

Sends a user message with a given message.

Link copied to clipboard
open override fun setTyping(isTyping: Boolean)

Sets the typing status.

Link copied to clipboard
open override fun updateUserMessage(messageId: Long, message: String)

Updates a message with a given messageId and message.