Merge branch 'main' into dependabot/gradle/ktorVer-2.0.2
This commit is contained in:
commit
16185e2d94
|
@ -127,7 +127,7 @@ ext.kotlinTest = { dependencies ->
|
||||||
dependencies.testImplementation Dependencies.mavenCentral.kotlinTest
|
dependencies.testImplementation Dependencies.mavenCentral.kotlinTest
|
||||||
dependencies.testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.6.10"
|
dependencies.testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.6.10"
|
||||||
dependencies.testImplementation 'io.mockk:mockk:1.12.4'
|
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.testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
|
||||||
dependencies.testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
|
dependencies.testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
|
||||||
|
|
|
@ -111,7 +111,7 @@ ext.Dependencies.with {
|
||||||
kotlinSerializationGradlePlugin = "org.jetbrains.kotlin:kotlin-serialization:${kotlinVer}"
|
kotlinSerializationGradlePlugin = "org.jetbrains.kotlin:kotlin-serialization:${kotlinVer}"
|
||||||
kotlinSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"
|
kotlinSerializationJson = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"
|
||||||
kotlinCoroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1"
|
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}"
|
kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVer}"
|
||||||
|
|
||||||
sqldelightGradlePlugin = "com.squareup.sqldelight:gradle-plugin:${sqldelightVer}"
|
sqldelightGradlePlugin = "com.squareup.sqldelight:gradle-plugin:${sqldelightVer}"
|
||||||
|
|
|
@ -65,17 +65,13 @@ internal class TimelineEventMapper(
|
||||||
|
|
||||||
private suspend fun ApiTimelineEvent.TimelineMessage.handleReply(replyToId: EventId, lookup: Lookup): RoomEvent {
|
private suspend fun ApiTimelineEvent.TimelineMessage.handleReply(replyToId: EventId, lookup: Lookup): RoomEvent {
|
||||||
val relationEvent = lookup(replyToId).fold(
|
val relationEvent = lookup(replyToId).fold(
|
||||||
onApiTimelineEvent = { it.toTextMessage() },
|
onApiTimelineEvent = { it.toMessage() },
|
||||||
onRoomEvent = { it },
|
onRoomEvent = { it },
|
||||||
onEmpty = { null }
|
onEmpty = { null }
|
||||||
)
|
)
|
||||||
|
|
||||||
return when (relationEvent) {
|
return when (relationEvent) {
|
||||||
null -> when (this.content) {
|
null -> this.toMessage()
|
||||||
is ApiTimelineEvent.TimelineMessage.Content.Image -> this.toImageMessage()
|
|
||||||
is ApiTimelineEvent.TimelineMessage.Content.Text -> this.toFallbackTextMessage()
|
|
||||||
ApiTimelineEvent.TimelineMessage.Content.Ignored -> throw IllegalStateException()
|
|
||||||
}
|
|
||||||
else -> {
|
else -> {
|
||||||
RoomEvent.Reply(
|
RoomEvent.Reply(
|
||||||
message = roomEventFactory.mapToRoomEvent(this),
|
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.toFallbackTextMessage() = this.toTextMessage(content = this.asTextContent().body ?: "redacted")
|
||||||
|
|
||||||
private suspend fun ApiTimelineEvent.TimelineMessage.handleEdit(editedEventId: EventId, lookup: Lookup): RoomEvent? {
|
private suspend fun ApiTimelineEvent.TimelineMessage.handleEdit(editedEventId: EventId, lookup: Lookup): RoomEvent? {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package app.dapk.st.matrix.sync.internal.sync
|
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.AvatarUrl
|
||||||
import app.dapk.st.matrix.common.RoomMember
|
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.common.convertMxUrToUrl
|
||||||
import app.dapk.st.matrix.sync.*
|
import app.dapk.st.matrix.sync.*
|
||||||
import app.dapk.st.matrix.sync.internal.request.ApiSyncRoom
|
import app.dapk.st.matrix.sync.internal.request.ApiSyncRoom
|
||||||
|
@ -61,13 +61,18 @@ private fun ApiSyncRoom.collectMembers(userCredentials: UserCredentials): List<R
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal fun List<RoomEvent>.findLastMessage(): LastMessage? {
|
internal fun List<RoomEvent>.findLastMessage(): LastMessage? {
|
||||||
return this.filterIsInstance<RoomEvent.Message>().firstOrNull()?.let {
|
return this.firstOrNull()?.let {
|
||||||
LastMessage(
|
LastMessage(
|
||||||
content = it.content,
|
content = it.toTextContent(),
|
||||||
utcTimestamp = it.utcTimestamp,
|
utcTimestamp = it.utcTimestamp,
|
||||||
author = it.author,
|
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()
|
||||||
|
}
|
Loading…
Reference in New Issue