From 49937beb9ad7e6928c06bcdadf0dcbe1c23581a5 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 3 Nov 2022 17:47:39 +0000 Subject: [PATCH] fix edits changing message order - was caused by the edited event timestamp replacing the original message, which in turn caused the message to be ordered as the latest message --- .../app/dapk/st/matrix/sync/internal/sync/RoomEventCreator.kt | 1 - .../dapk/st/matrix/sync/internal/sync/RoomEventCreatorTest.kt | 4 ++-- 2 files changed, 2 insertions(+), 3 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 d291f6f..5ee8a21 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 @@ -152,7 +152,6 @@ internal class TimelineEventMapper( private fun RoomEvent.Message.edited(edit: ApiTimelineEvent.TimelineMessage) = this.copy( content = richMessageParser.parse(edit.asTextContent().let { it.formattedBody ?: it.body }?.removePrefix(" * ") ?: "redacted"), - utcTimestamp = edit.utcTimestamp, edited = true, ) diff --git a/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomEventCreatorTest.kt b/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomEventCreatorTest.kt index 9932bc7..45ab70b 100644 --- a/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomEventCreatorTest.kt +++ b/matrix/services/sync/src/test/kotlin/app/dapk/st/matrix/sync/internal/sync/RoomEventCreatorTest.kt @@ -146,7 +146,7 @@ internal class RoomEventCreatorTest { result shouldBeEqualTo aMatrixRoomMessageEvent( eventId = originalMessage.eventId, - utcTimestamp = editedMessage.utcTimestamp, + utcTimestamp = originalMessage.utcTimestamp, content = A_TEXT_EVENT_MESSAGE, author = A_SENDER, edited = true @@ -166,7 +166,7 @@ internal class RoomEventCreatorTest { replyingTo = originalMessage.replyingTo, message = aMatrixRoomMessageEvent( eventId = originalMessage.eventId, - utcTimestamp = editedMessage.utcTimestamp, + utcTimestamp = originalMessage.utcTimestamp, content = A_TEXT_EVENT_MESSAGE, author = A_SENDER, edited = true