Skip to content
Merged
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 @@ -7234,6 +7234,7 @@ public final class io/getstream/chat/android/compose/viewmodel/messages/MessageL
public final fun flagUser (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V
public static synthetic fun flagUser$default (Lio/getstream/chat/android/compose/viewmodel/messages/MessageListViewModel;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)V
public final fun getChannel ()Lio/getstream/chat/android/models/Channel;
public final fun getChannelState ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getConnectionState ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getCurrentMessagesState ()Landroidx/compose/runtime/State;
public final fun getEvents ()Lkotlinx/coroutines/flow/SharedFlow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.runtime.getValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import io.getstream.chat.android.client.api.state.ThreadState
import io.getstream.chat.android.client.channel.state.ChannelState
import io.getstream.chat.android.compose.util.extensions.asState
import io.getstream.chat.android.models.Channel
import io.getstream.chat.android.models.ConnectionState
Expand Down Expand Up @@ -91,6 +92,11 @@ public class MessageListViewModel(
*/
public val channel: Channel by messageListController.channel.asState(viewModelScope)

/**
* Holds information about the current channel and is actively updated.
*/
public val channelState: StateFlow<ChannelState?> = messageListController.channelState

/**
* The list of typing users.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.runTest
import org.amshove.kluent.`should be equal to`
import org.amshove.kluent.`should not be`
import org.junit.jupiter.api.Assertions.assertSame
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
import org.mockito.kotlin.any
Expand Down Expand Up @@ -134,6 +135,18 @@ internal class MessageListViewModelTest {
verify(chatClient).sendReaction(eq(reaction1), eq(false), eq(CID), eq(true))
}

@Test
fun `channelState exposes the channel state the message list observes`() = runTest {
val fixture = Fixture()
.givenCurrentUser()
.givenChannelQuery()
.givenChannelState()
val viewModel = fixture.get()

assertSame(fixture.channelState, viewModel.channelState.value)
Comment thread
andremion marked this conversation as resolved.
assertSame(viewModel.messageListController.channelState, viewModel.channelState)
}

@Test
fun `When calling pauseAudioRecordingAttachments, audioPlayer is invoked`() = runTest {
val audioPlayer = mock<AudioPlayer>()
Expand Down Expand Up @@ -171,7 +184,7 @@ internal class MessageListViewModelTest {
private val clientState: ClientState = mock()
private val stateRegistry: StateRegistry = mock()
private val globalState: GlobalState = mock()
private val channelState: ChannelState = mock()
val channelState: ChannelState = mock()

init {
val statePlugin: StatePlugin = mock()
Expand Down
Loading