Merge branch 'main' of github.com:ouchadam/helium into feature/message-formatting

This commit is contained in:
Adam Brown 2022-10-24 22:19:20 +01:00
commit de8c476ed5
3 changed files with 20 additions and 18 deletions

View File

@ -146,7 +146,7 @@ ext.Dependencies.with {
accompanistSystemuicontroller = "com.google.accompanist:accompanist-systemuicontroller:0.25.1"
junit = "junit:junit:4.13.2"
kluent = "org.amshove.kluent:kluent:1.71"
kluent = "org.amshove.kluent:kluent:1.72"
mockk = 'io.mockk:mockk:1.13.2'
matrixOlm = "org.matrix.android:olm-sdk:3.2.12"

View File

@ -200,29 +200,31 @@ private fun ColumnScope.RoomContent(self: UserId, state: RoomState, messageActio
wasPreviousMessageSameSender = wasPreviousMessageSameSender,
onReply = { messageActions.onReply(item) },
) {
val event = BubbleModel.Event(item.author.id.value, item.author.displayName ?: item.author.id.value, item.edited, item.time)
val status = @Composable { SendStatus(item) }
MessageBubble(this, item.toModel(event), status, onLongClick = messageActions.onLongClick)
MessageBubble(this, item.toModel(), status, onLongClick = messageActions.onLongClick)
}
}
}
}
@Composable
private fun RoomEvent.toModel(event: BubbleModel.Event): BubbleModel = when (this) {
is RoomEvent.Message -> BubbleModel.Text(this.content.toApp(), event)
is RoomEvent.Encrypted -> BubbleModel.Encrypted(event)
is RoomEvent.Image -> {
val imageRequest = LocalImageRequestFactory.current
.memoryCacheKey(this.imageMeta.url)
.data(this)
.build()
val imageContent = BubbleModel.Image.ImageContent(this.imageMeta.width, this.imageMeta.height, this.imageMeta.url)
BubbleModel.Image(imageContent, imageRequest, event)
}
private fun RoomEvent.toModel(): BubbleModel {
val event = BubbleModel.Event(this.author.id.value, this.author.displayName ?: this.author.id.value, this.edited, this.time)
return when (this) {
is RoomEvent.Message -> BubbleModel.Text(this.content.toApp(), event)
is RoomEvent.Encrypted -> BubbleModel.Encrypted(event)
is RoomEvent.Image -> {
val imageRequest = LocalImageRequestFactory.current
.memoryCacheKey(this.imageMeta.url)
.data(this)
.build()
val imageContent = BubbleModel.Image.ImageContent(this.imageMeta.width, this.imageMeta.height, this.imageMeta.url)
BubbleModel.Image(imageContent, imageRequest, event)
}
is RoomEvent.Reply -> {
BubbleModel.Reply(this.replyingTo.toModel(event), this.message.toModel(event))
is RoomEvent.Reply -> {
BubbleModel.Reply(this.replyingTo.toModel(), this.message.toModel())
}
}
}

View File

@ -1,4 +1,4 @@
{
"code": 22,
"name": "17/10/2022-V1"
"code": 23,
"name": "24/10/2022-V1"
}