-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4889] Migration guide for MessagesScreen (#4890)
Co-authored-by: kanat <>
- Loading branch information
Showing
2 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ocs/Android/02-migration-guides/04-compose-ui-components/02-messages-screen.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# 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. | ||
|
||
:::note | ||
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: | ||
|
||
```kotlin | ||
@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: | ||
```kotlin | ||
@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](./01-message-list-viewmodel.mdx). | ||
|
||
## More Information | ||
You can find more docs about the `MessagesScreen` component and its' customization [here](../../05-compose/05-message-components/01-messages-screen.mdx). | ||
|