MessagesScreen

Previously, MessagesScreen component was internally creating MessagesViewModelFactory by utilizing the given component parameters. In the new version, you are required to provide a MessagesViewModelFactory instance to MessagesScreen, which will be used for creating the required ViewModels.

Component Parameters

Since the MessagesViewModelFactory is passed directly to the MessagesScreen component, the following parameters were removed from MessagesScreen component:

  • channelId: String - The ID of the opened/active Channel.
  • messageLimit: Int - The limit of messages per query.
  • enforceUniqueReactions: Boolean - If we need to enforce unique reactions or not.
  • showDateSeparators: Boolean - If we should show date separators or not.
  • showSystemMessages: Boolean - If we should show system messages or not.
  • deletedMessageVisibility: DeletedMessageVisibility - The behavior of deleted messages in the list and if they’re visible or not.
  • messageFooterVisibility: MessageFooterVisibility - The behavior of message footers in the list and their visibility.
  • messageId: String? - The ID of the message which we wish to focus on, if such exists.
  • navigateToThreadViaNotification: Boolean - If true, when a thread message arrives in a push notification, clicking it will automatically open the thread in which the message is located. If false, the SDK will always.

The parameter navigateToThreadViaNotification: Boolean has been removed from both MessagesScreen and MessagesViewModelFactory as navigating to thread messages via push notifications is the default behavior in v6.

The MessagesScreen signature in v5 looked like this:

@Composable
public fun MessagesScreen(
    channelId: String,
    messageLimit: Int = MessageListViewModel.DefaultMessageLimit,
    showHeader: Boolean = true,
    enforceUniqueReactions: Boolean = true,
    showDateSeparators: Boolean = true,
    showSystemMessages: Boolean = true,
    deletedMessageVisibility: DeletedMessageVisibility = DeletedMessageVisibility.ALWAYS_VISIBLE,
    messageFooterVisibility: MessageFooterVisibility = MessageFooterVisibility.WithTimeDifference(),
    onBackPressed: () -> Unit = {},
    onHeaderActionClick: (channel: Channel) -> Unit = {},
    messageId: String? = null,
    navigateToThreadViaNotification: Boolean = false,
    skipPushNotification: Boolean = false,
    skipEnrichUrl: Boolean = false,
    threadMessagesStart: ThreadMessagesStart = ThreadMessagesStart.BOTTOM,
) 

And the signature of MessagesScreen in v6 looks like this:

@Composable
public fun MessagesScreen(
    viewModelFactory: MessagesViewModelFactory,
    showHeader: Boolean = true,
    onBackPressed: () -> Unit = {},
    onHeaderTitleClick: (channel: Channel) -> Unit = {},
    onChannelAvatarClick: () -> Unit = {},
    skipPushNotification: Boolean = false,
    skipEnrichUrl: Boolean = false,
    threadMessagesStart: ThreadMessagesStart = ThreadMessagesStart.BOTTOM,
    statefulStreamMediaRecorder: StatefulStreamMediaRecorder? = null,
)

MessagesViewModelFactory

Migration changes related to MessagesViewModelFactory can be found here here.

More Information

You can find more docs about the MessagesScreen component and its’ customization here.

© Getstream.io, Inc. All Rights Reserved.