[Chat][Feature] participant system messages (#525)

This commit is contained in:
Adam Hammer 2022-10-19 15:13:38 -07:00 коммит произвёл GitHub
Родитель e0b3b1f4b0
Коммит e231b63ead
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 32 добавлений и 10 удалений

Просмотреть файл

@ -15,6 +15,7 @@ internal data class MessageInfoModel(
val internalId: String? = null,
val messageType: ChatMessageType?,
val content: String?,
val participants: List<String> = emptyList(),
val version: String? = null,
val senderDisplayName: String? = null,
val createdOn: OffsetDateTime? = null,
@ -29,6 +30,7 @@ internal fun com.azure.android.communication.chat.models.ChatMessage.into(): Mes
id = this.id,
messageType = this.type.into(),
content = this.content.message,
participants = this.content.participants?.map { it.displayName }?.toList() ?: emptyList(),
internalId = null,
version = this.version,
senderDisplayName = this.senderDisplayName,
@ -46,6 +48,7 @@ internal fun com.azure.android.communication.chat.models.ChatMessageReceivedEven
messageType = this.type.into(),
version = this.version,
content = this.content,
participants = emptyList(),
senderCommunicationIdentifier = this.sender.into(),
senderDisplayName = this.senderDisplayName,
createdOn = this.createdOn,
@ -61,6 +64,7 @@ internal fun com.azure.android.communication.chat.models.ChatMessageEditedEvent.
messageType = null,
version = this.version,
content = this.content,
participants = emptyList(),
senderCommunicationIdentifier = this.sender.into(),
senderDisplayName = this.senderDisplayName,
createdOn = this.createdOn,
@ -76,6 +80,7 @@ internal fun com.azure.android.communication.chat.models.ChatMessageDeletedEvent
messageType = null,
version = this.version,
content = null,
participants = emptyList(),
senderCommunicationIdentifier = this.sender.into(),
senderDisplayName = this.senderDisplayName,
createdOn = this.createdOn,
@ -88,6 +93,7 @@ internal val EMPTY_MESSAGE_INFO_MODEL = MessageInfoModel(
id = "",
messageType = null,
content = "",
participants = emptyList(),
internalId = "",
version = "",
senderDisplayName = "",

Просмотреть файл

@ -47,18 +47,32 @@ internal fun MessageView(viewModel: MessageViewModel) {
@Composable
private fun UserJoinedMessage(viewModel: MessageViewModel) {
BasicText(
"${viewModel.message.senderDisplayName} joined the chat",
style = ChatCompositeTheme.typography.systemMessage
)
if (viewModel.message.participants.size <= 1) {
BasicText(
"${viewModel.message.participants.firstOrNull() ?: "Unknown"} joined the chat",
style = ChatCompositeTheme.typography.systemMessage
)
} else {
BasicText(
"${viewModel.message.participants.joinToString(", ")} joined the chat",
style = ChatCompositeTheme.typography.systemMessage
)
}
}
@Composable
private fun UserLeftMessage(viewModel: MessageViewModel) {
BasicText(
"${viewModel.message.senderDisplayName} left the chat",
style = ChatCompositeTheme.typography.systemMessage
)
if (viewModel.message.participants.size <= 1) {
BasicText(
"${viewModel.message.participants.firstOrNull() ?: "Unknown"} left the chat",
style = ChatCompositeTheme.typography.systemMessage
)
} else {
BasicText(
"${viewModel.message.participants.joinToString(", ")} left the chat",
style = ChatCompositeTheme.typography.systemMessage
)
}
}
@Composable

Просмотреть файл

@ -44,7 +44,8 @@ internal val MOCK_MESSAGES get(): List<MessageInfoModel> {
content = null,
messageType = ChatMessageType.PARTICIPANT_ADDED,
senderCommunicationIdentifier = userC_ID,
senderDisplayName = userC_Display,
participants = listOf(userC_Display, userA_Display),
senderDisplayName = null,
id = null,
internalId = null
),
@ -61,7 +62,8 @@ internal val MOCK_MESSAGES get(): List<MessageInfoModel> {
content = null,
messageType = ChatMessageType.PARTICIPANT_REMOVED,
senderCommunicationIdentifier = userD_ID,
senderDisplayName = userD_Display,
senderDisplayName = null,
participants = listOf(userD_Display),
id = null,
internalId = null
),