From 7a05bd7fb5d1892b3d78932b96bb8755aae92fda Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 05:36:12 +0000 Subject: [PATCH 1/3] Bump kotlinx-coroutines-test from 1.6.1 to 1.6.2 Bumps [kotlinx-coroutines-test](https://github.com/Kotlin/kotlinx.coroutines) from 1.6.1 to 1.6.2. - [Release notes](https://github.com/Kotlin/kotlinx.coroutines/releases) - [Changelog](https://github.com/Kotlin/kotlinx.coroutines/blob/master/CHANGES.md) - [Commits](https://github.com/Kotlin/kotlinx.coroutines/compare/1.6.1...1.6.2) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-coroutines-test dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- dependencies.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 919d030..7826dc6 100644 --- a/build.gradle +++ b/build.gradle @@ -127,7 +127,7 @@ ext.kotlinTest = { dependencies -> dependencies.testImplementation Dependencies.mavenCentral.kotlinTest dependencies.testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.6.10" dependencies.testImplementation 'io.mockk:mockk:1.12.4' - dependencies.testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1' + dependencies.testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.2' dependencies.testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' dependencies.testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' diff --git a/dependencies.gradle b/dependencies.gradle index d3b0344..6d72eaf 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -111,7 +111,7 @@ ext.Dependencies.with { kotlinSerializationGradlePlugin = "org.jetbrains.kotlin:kotlin-serialization:${kotlinVer}" kotlinSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3" kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1" - kotlinCoroutinesTest = 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1' + kotlinCoroutinesTest = 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.2' kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVer}" sqldelightGradlePlugin = "com.squareup.sqldelight:gradle-plugin:${sqldelightVer}" From a6fa7487f385ffe666abf88cf68b5d7acff7ed79 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 30 May 2022 18:05:45 +0100 Subject: [PATCH 2/3] supporting images and replies in the room list --- .../st/matrix/sync/internal/sync/RoomProcessor.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomProcessor.kt b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomProcessor.kt index ede6715..f851f46 100644 --- a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomProcessor.kt +++ b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomProcessor.kt @@ -1,8 +1,8 @@ package app.dapk.st.matrix.sync.internal.sync -import app.dapk.st.matrix.common.UserCredentials import app.dapk.st.matrix.common.AvatarUrl import app.dapk.st.matrix.common.RoomMember +import app.dapk.st.matrix.common.UserCredentials import app.dapk.st.matrix.common.convertMxUrToUrl import app.dapk.st.matrix.sync.* import app.dapk.st.matrix.sync.internal.request.ApiSyncRoom @@ -61,13 +61,18 @@ private fun ApiSyncRoom.collectMembers(userCredentials: UserCredentials): List.findLastMessage(): LastMessage? { - return this.filterIsInstance().firstOrNull()?.let { + return this.firstOrNull()?.let { LastMessage( - content = it.content, + content = it.toTextContent(), utcTimestamp = it.utcTimestamp, author = it.author, ) } } + +private fun RoomEvent.toTextContent(): String = when (this) { + is RoomEvent.Image -> "\uD83D\uDCF7" + is RoomEvent.Message -> this.content + is RoomEvent.Reply -> this.message.toTextContent() +} \ No newline at end of file From c2c6296e9aefd98832015b913b1a9b799d1b0703 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 7 Jun 2022 19:55:36 +0100 Subject: [PATCH 3/3] fixing missing nested replies/images --- .../matrix/sync/internal/sync/RoomEventCreator.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomEventCreator.kt b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomEventCreator.kt index 09fd61e..7363989 100644 --- a/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomEventCreator.kt +++ b/matrix/services/sync/src/main/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomEventCreator.kt @@ -65,17 +65,13 @@ internal class TimelineEventMapper( private suspend fun ApiTimelineEvent.TimelineMessage.handleReply(replyToId: EventId, lookup: Lookup): RoomEvent { val relationEvent = lookup(replyToId).fold( - onApiTimelineEvent = { it.toTextMessage() }, + onApiTimelineEvent = { it.toMessage() }, onRoomEvent = { it }, onEmpty = { null } ) return when (relationEvent) { - null -> when (this.content) { - is ApiTimelineEvent.TimelineMessage.Content.Image -> this.toImageMessage() - is ApiTimelineEvent.TimelineMessage.Content.Text -> this.toFallbackTextMessage() - ApiTimelineEvent.TimelineMessage.Content.Ignored -> throw IllegalStateException() - } + null -> this.toMessage() else -> { RoomEvent.Reply( message = roomEventFactory.mapToRoomEvent(this), @@ -89,6 +85,12 @@ internal class TimelineEventMapper( } } + private suspend fun ApiTimelineEvent.TimelineMessage.toMessage() = when (this.content) { + is ApiTimelineEvent.TimelineMessage.Content.Image -> this.toImageMessage() + is ApiTimelineEvent.TimelineMessage.Content.Text -> this.toFallbackTextMessage() + ApiTimelineEvent.TimelineMessage.Content.Ignored -> throw IllegalStateException() + } + private suspend fun ApiTimelineEvent.TimelineMessage.toFallbackTextMessage() = this.toTextMessage(content = this.asTextContent().body ?: "redacted") private suspend fun ApiTimelineEvent.TimelineMessage.handleEdit(editedEventId: EventId, lookup: Lookup): RoomEvent? {