Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7031,17 +7031,9 @@ public final class io/getstream/chat/android/compose/viewmodel/messages/MessageC
public final fun completeRecording ()V
public final fun createPoll (Lio/getstream/chat/android/models/CreatePollParams;)V
public final fun dismissMessageActions ()V
public final fun getCommandSuggestions ()Lkotlinx/coroutines/flow/MutableStateFlow;
public final fun getCooldownTimer ()Lkotlinx/coroutines/flow/MutableStateFlow;
public final fun getInputFocusEvents ()Lkotlinx/coroutines/flow/SharedFlow;
public final fun getLastActiveAction ()Lkotlinx/coroutines/flow/Flow;
public final fun getLinkPreviews ()Lkotlinx/coroutines/flow/MutableStateFlow;
public final fun getMentionSuggestions ()Lkotlinx/coroutines/flow/MutableStateFlow;
public final fun getMessageComposerState ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getMessageInput ()Lkotlinx/coroutines/flow/MutableStateFlow;
public final fun getMessageMode ()Lkotlinx/coroutines/flow/MutableStateFlow;
public final fun getOwnCapabilities ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getValidationErrors ()Lkotlinx/coroutines/flow/MutableStateFlow;
public final fun getMessageInput ()Lkotlinx/coroutines/flow/StateFlow;
public final fun holdRecording (Lkotlin/Pair;)V
public final fun leaveThread ()V
public final fun lockRecording ()V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public fun AttachmentPickerMenu(
composerViewModel: MessageComposerViewModel,
) {
val isPickerVisible = attachmentsPickerViewModel.isPickerVisible
val messageMode by composerViewModel.messageMode.collectAsStateWithLifecycle()
val composerState by composerViewModel.messageComposerState.collectAsStateWithLifecycle()

var isShowingDialog by rememberSaveable { mutableStateOf(false) }

Expand Down Expand Up @@ -131,7 +131,7 @@ public fun AttachmentPickerMenu(
params = AttachmentPickerParams(
modifier = Modifier.height(menuHeight),
attachmentsPickerViewModel = attachmentsPickerViewModel,
messageMode = messageMode,
messageMode = composerState.messageMode,
actions = actions,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ package io.getstream.chat.android.compose.viewmodel.messages

import androidx.lifecycle.ViewModel
import io.getstream.chat.android.models.Attachment
import io.getstream.chat.android.models.ChannelCapabilities
import io.getstream.chat.android.models.Command
import io.getstream.chat.android.models.CreatePollParams
import io.getstream.chat.android.models.LinkPreview
import io.getstream.chat.android.models.Message
import io.getstream.chat.android.models.User
import io.getstream.chat.android.ui.common.feature.messages.composer.MessageComposerController
Expand All @@ -33,11 +31,8 @@ import io.getstream.chat.android.ui.common.state.messages.MessageInput
import io.getstream.chat.android.ui.common.state.messages.MessageMode
import io.getstream.chat.android.ui.common.state.messages.Reply
import io.getstream.chat.android.ui.common.state.messages.composer.MessageComposerState
import io.getstream.chat.android.ui.common.state.messages.composer.ValidationError
import io.getstream.chat.android.ui.common.utils.typing.TypingUpdatesBuffer
import io.getstream.result.call.Call
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow

Expand Down Expand Up @@ -68,52 +63,7 @@ public class MessageComposerViewModel(
/**
* UI state of the current composer input.
*/
public val messageInput: MutableStateFlow<MessageInput> = messageComposerController.messageInput

/**
* Represents the remaining time until the user is allowed to send the next message.
*/
public val cooldownTimer: MutableStateFlow<Int> = messageComposerController.cooldownTimer

/**
* Represents the list of validation errors for the current text input and the currently selected attachments.
*/
public val validationErrors: MutableStateFlow<List<ValidationError>> = messageComposerController.validationErrors

/**
* Represents the list of users that can be used to autocomplete the current mention input.
*/
public val mentionSuggestions: MutableStateFlow<List<User>> = messageComposerController.mentionSuggestions

/**
* Represents the list of commands to be displayed in the command suggestion list popup.
*/
public val commandSuggestions: MutableStateFlow<List<Command>> = messageComposerController.commandSuggestions

/**
* Represents the list of links that can be previewed.
*/
public val linkPreviews: MutableStateFlow<List<LinkPreview>> = messageComposerController.linkPreviews

/**
* Current message mode, either [MessageMode.Normal] or [MessageMode.MessageThread]. Used to determine if we're
* sending a thread reply or a regular message.
*/
public val messageMode: MutableStateFlow<MessageMode> = messageComposerController.messageMode

/**
* Gets the active [Edit] or [Reply] action, whichever is last, to show on the UI.
*/
public val lastActiveAction: Flow<MessageAction?> = messageComposerController.lastActiveAction

/**
* 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].
*/
public val ownCapabilities: StateFlow<Set<String>> = messageComposerController.ownCapabilities
public val messageInput: StateFlow<MessageInput> = messageComposerController.messageInput

/**
* Called when the input changes and the internal state needs to be updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ internal class MessageComposerViewModelTest {

val messageComposerState = viewModel.messageComposerState.value
messageComposerState.messageMode `should be instance of` MessageMode.MessageThread::class
viewModel.messageMode.value `should be instance of` MessageMode.MessageThread::class
}

@Test
Expand All @@ -263,7 +262,6 @@ internal class MessageComposerViewModelTest {

val messageComposerState = viewModel.messageComposerState.value
messageComposerState.messageMode `should be instance of` MessageMode.Normal::class
viewModel.messageMode.value `should be instance of` MessageMode.Normal::class
}

@Test
Expand Down Expand Up @@ -311,7 +309,7 @@ internal class MessageComposerViewModelTest {
.givenChannelState(channelData)
.get()

val ownCapabilities = viewModel.ownCapabilities.value
val ownCapabilities = viewModel.messageComposerState.value.ownCapabilities
ownCapabilities.size `should be equal to` 3
}

Expand All @@ -326,7 +324,6 @@ internal class MessageComposerViewModelTest {
viewModel.setMessageInput("/")

viewModel.messageComposerState.value.commandSuggestions.size `should be equal to` 1
viewModel.commandSuggestions.value.size `should be equal to` 1
}

@Test
Expand All @@ -341,7 +338,6 @@ internal class MessageComposerViewModelTest {
viewModel.setMessageInput("")

viewModel.messageComposerState.value.commandSuggestions.size `should be equal to` 0
viewModel.commandSuggestions.value.size `should be equal to` 0
}

@Test
Expand All @@ -355,10 +351,9 @@ internal class MessageComposerViewModelTest {

viewModel.inputFocusEvents.test {
viewModel.toggleCommandsVisibility()
viewModel.selectCommand(viewModel.commandSuggestions.value.first())
viewModel.selectCommand(viewModel.messageComposerState.value.commandSuggestions.first())

viewModel.messageComposerState.value.commandSuggestions.size `should be equal to` 0
viewModel.commandSuggestions.value.size `should be equal to` 0
viewModel.messageComposerState.value.inputValue `should be equal to` "/giphy "
viewModel.messageInput.value.text `should be equal to` "/giphy "
awaitItem()
Expand All @@ -381,7 +376,6 @@ internal class MessageComposerViewModelTest {
advanceUntilIdle()

viewModel.messageComposerState.value.mentionSuggestions.size `should be equal to` 2
viewModel.mentionSuggestions.value.size `should be equal to` 2
}

@Test
Expand All @@ -398,11 +392,10 @@ internal class MessageComposerViewModelTest {
viewModel.setMessageInput("@")
advanceUntilIdle()

viewModel.selectMention(viewModel.mentionSuggestions.value.first())
viewModel.selectMention(viewModel.messageComposerState.value.mentionSuggestions.first())
advanceUntilIdle()

viewModel.messageComposerState.value.mentionSuggestions.size `should be equal to` 0
viewModel.mentionSuggestions.value.size `should be equal to` 0
viewModel.messageInput.value.text `should be equal to` "@Jc Miñarro "
}

Expand All @@ -429,7 +422,6 @@ internal class MessageComposerViewModelTest {
advanceUntilIdle()

viewModel.messageComposerState.value.mentionSuggestions.size `should be equal to` 0
viewModel.mentionSuggestions.value.size `should be equal to` 0
viewModel.messageInput.value.text `should be equal to` "@Custom Mention "
}

Expand Down
Loading
Loading