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 @@ -29,7 +29,7 @@ fun MacrobenchmarkScope.messagesExplore() = device.apply {
}

fun MacrobenchmarkScope.messagesWaitForContent() = device.apply {
wait(Until.hasObject(By.res("Stream_MessagesScreen")), STANDARD_TIMEOUT)
wait(Until.hasObject(By.res("Stream_ChannelScreen")), STANDARD_TIMEOUT)
}

fun MacrobenchmarkScope.messagesScrollDownUp() = device.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ import io.getstream.chat.android.compose.ui.components.avatar.AvatarSize
import io.getstream.chat.android.compose.ui.components.avatar.UserAvatar
import io.getstream.chat.android.compose.ui.messages.composer.MessageComposer
import io.getstream.chat.android.compose.ui.theme.ChatTheme
import io.getstream.chat.android.compose.viewmodel.messages.ChannelViewModelFactory
import io.getstream.chat.android.compose.viewmodel.messages.MessageComposerViewModel
import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory
import io.getstream.chat.android.models.User

/**
Expand Down Expand Up @@ -101,7 +101,7 @@ fun AddChannelScreen(
state.draftCid?.let { cid ->
val context = LocalContext.current
val viewModel = remember(cid) {
val factory = MessagesViewModelFactory(context, cid)
val factory = ChannelViewModelFactory(context, cid)
factory.create(MessageComposerViewModel::class.java)
}
MessageComposer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import io.getstream.chat.android.compose.ui.components.LoadingIndicator
import io.getstream.chat.android.compose.ui.messages.composer.MessageComposer
import io.getstream.chat.android.compose.ui.messages.header.MessageListHeader
import io.getstream.chat.android.compose.ui.messages.header.ChannelHeader
import io.getstream.chat.android.compose.ui.theme.ChatTheme
import io.getstream.chat.android.compose.ui.theme.MessageListEmptyContentParams
import io.getstream.chat.android.compose.viewmodel.channel.ChannelHeaderViewModel
import io.getstream.chat.android.compose.viewmodel.channel.ChannelHeaderViewModelFactory
import io.getstream.chat.android.compose.viewmodel.messages.ChannelViewModelFactory
import io.getstream.chat.android.compose.viewmodel.messages.MessageComposerViewModel
import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory
import io.getstream.chat.android.ui.common.state.messages.list.ChannelHeaderViewState

@Composable
Expand Down Expand Up @@ -105,7 +105,7 @@ private fun DraftChannelTopBar(
modifier = Modifier.fillMaxWidth(),
)

is ChannelHeaderViewState.Content -> MessageListHeader(
is ChannelHeaderViewState.Content -> ChannelHeader(
channel = content.channel,
currentUser = content.currentUser,
connectionState = content.connectionState,
Expand All @@ -120,7 +120,7 @@ private fun DraftChannelBottomBar(
onMessageSent: () -> Unit,
) {
val context = LocalContext.current
val viewModel = viewModel<MessageComposerViewModel>(key = cid, factory = MessagesViewModelFactory(context, cid))
val viewModel = viewModel<MessageComposerViewModel>(key = cid, factory = ChannelViewModelFactory(context, cid))
MessageComposer(
viewModel = viewModel,
onSendMessage = { message ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import io.getstream.chat.android.compose.ui.theme.ChannelOptionsTheme
import io.getstream.chat.android.compose.ui.theme.ChatTheme
import io.getstream.chat.android.compose.ui.threads.ThreadList
import io.getstream.chat.android.compose.viewmodel.channels.ChannelListViewModel
import io.getstream.chat.android.compose.viewmodel.channels.ChannelViewModelFactory
import io.getstream.chat.android.compose.viewmodel.channels.ChannelListViewModelFactory
import io.getstream.chat.android.compose.viewmodel.mentions.MentionListViewModel
import io.getstream.chat.android.compose.viewmodel.mentions.MentionListViewModelFactory
import io.getstream.chat.android.compose.viewmodel.threads.ThreadListViewModel
Expand All @@ -114,7 +114,7 @@ class ChannelsActivity : ComponentActivity() {
private val channelsViewModelFactory by lazy {
val chatClient = ChatClient.instance()
val currentUserId = chatClient.getCurrentUser()?.id ?: ""
ChannelViewModelFactory(
ChannelListViewModelFactory(
chatClient = chatClient,
querySort = QuerySortByField
.descByName<Channel>("pinned_at") // pinned channels first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import io.getstream.chat.android.compose.sample.ui.component.CustomChatComponent
import io.getstream.chat.android.compose.sample.ui.component.CustomMentionStyleFactory
import io.getstream.chat.android.compose.sample.vm.SharedLocationViewModelFactory
import io.getstream.chat.android.compose.ui.components.messageoptions.MessageOptionItemVisibility
import io.getstream.chat.android.compose.ui.messages.MessagesScreen
import io.getstream.chat.android.compose.ui.messages.ChannelScreen
import io.getstream.chat.android.compose.ui.theme.AttachmentPickerConfig
import io.getstream.chat.android.compose.ui.theme.ChatTheme
import io.getstream.chat.android.compose.ui.theme.ChatUiConfig
Expand All @@ -44,7 +44,7 @@ import io.getstream.chat.android.compose.ui.theme.MessageComposerTheme
import io.getstream.chat.android.compose.ui.theme.MessageOptionsTheme
import io.getstream.chat.android.compose.ui.theme.ReactionOptionsTheme
import io.getstream.chat.android.compose.ui.theme.StreamDesign
import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory
import io.getstream.chat.android.compose.viewmodel.messages.ChannelViewModelFactory
import io.getstream.chat.android.models.Channel
import io.getstream.chat.android.models.ReactionSortingByLastReactionAt
import io.getstream.chat.android.ui.common.state.messages.list.DeletedMessageVisibility
Expand All @@ -58,7 +58,7 @@ class MessagesActivity : ComponentActivity() {
}

private val factory by lazy {
MessagesViewModelFactory(
ChannelViewModelFactory(
context = this,
channelId = cid,
isComposerLinkPreviewEnabled = ChatApp.isComposerLinkPreviewEnabled,
Expand Down Expand Up @@ -121,7 +121,7 @@ class MessagesActivity : ComponentActivity() {

@Composable
private fun SetupContent() {
MessagesScreen(
ChannelScreen(
viewModelFactory = factory,
reactionSorting = ReactionSortingByLastReactionAt,
onBackPressed = { finish() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ import io.getstream.chat.android.compose.viewmodel.channel.ChannelAttachmentsVie
import io.getstream.chat.android.compose.viewmodel.channel.ChannelAttachmentsViewModelFactory
import io.getstream.chat.android.compose.viewmodel.channel.ChannelInfoViewModel
import io.getstream.chat.android.compose.viewmodel.channel.ChannelInfoViewModelFactory
import io.getstream.chat.android.compose.viewmodel.channels.ChannelViewModelFactory
import io.getstream.chat.android.compose.viewmodel.messages.MessagesViewModelFactory
import io.getstream.chat.android.compose.viewmodel.channels.ChannelListViewModelFactory
import io.getstream.chat.android.compose.viewmodel.messages.ChannelViewModelFactory
import io.getstream.chat.android.compose.viewmodel.pinned.PinnedMessageListViewModel
import io.getstream.chat.android.compose.viewmodel.pinned.PinnedMessageListViewModelFactory
import io.getstream.chat.android.models.AttachmentType
Expand Down Expand Up @@ -130,10 +130,10 @@ class ChatsActivity : ComponentActivity() {
private val messageId by lazy { intent.getStringExtra(KEY_MESSAGE_ID) }
private val parentMessageId by lazy { intent.getStringExtra(KEY_PARENT_MESSAGE_ID) }

private val channelViewModelFactory by lazy {
private val channelListViewModelFactory by lazy {
val chatClient = ChatClient.instance()
val currentUserId = chatClient.getCurrentUser()?.id ?: ""
ChannelViewModelFactory(
ChannelListViewModelFactory(
chatClient = chatClient,
querySort = QuerySortByField
.descByName<Channel>("pinned_at") // pinned channels first
Expand All @@ -147,9 +147,9 @@ class ChatsActivity : ComponentActivity() {
)
}

private val messagesViewModelFactory by lazy {
private val channelViewModelFactory by lazy {
channelId?.let { cid ->
buildMessagesViewModelFactory(
buildChannelViewModelFactory(
channelId = cid,
messageId = messageId,
parentMessageId = parentMessageId,
Expand Down Expand Up @@ -183,12 +183,12 @@ class ChatsActivity : ComponentActivity() {
val navigator = rememberThreePaneNavigator()
ChatsScreen(
navigator = navigator,
channelViewModelFactory = channelViewModelFactory,
messagesViewModelFactoryProvider = { _, (channelId, messageId, parentMessageId) ->
channelListViewModelFactory = channelListViewModelFactory,
channelViewModelFactoryProvider = { _, (channelId, messageId, parentMessageId) ->
if (channelId == null) {
messagesViewModelFactory
channelViewModelFactory
} else {
buildMessagesViewModelFactory(
buildChannelViewModelFactory(
channelId = channelId,
messageId = messageId,
parentMessageId = parentMessageId,
Expand Down Expand Up @@ -604,11 +604,11 @@ class ChatsActivity : ComponentActivity() {
}
}

private fun buildMessagesViewModelFactory(
private fun buildChannelViewModelFactory(
channelId: String,
messageId: String?,
parentMessageId: String?,
) = MessagesViewModelFactory(
) = ChannelViewModelFactory(
context = applicationContext,
channelId = channelId,
messageId = messageId,
Expand Down
Loading
Loading