From 47aa787ecb91aab8e0729b44bee650360bb6262b Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sat, 1 May 2021 09:29:31 +0200 Subject: [PATCH] Fix missing sender information after edits Fixes https://github.com/vector-im/element-android/issues/3184 --- CHANGES.md | 1 + .../android/sdk/api/session/room/timeline/TimelineEvent.kt | 5 +++++ .../detail/timeline/helper/MessageInformationDataFactory.kt | 2 ++ 3 files changed, 8 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 1c0b7284b0..c40c66a0b2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Bugfix 🐛: - Fix issues on Android 11 (#3067) - Fix issue when opening encrypted files (#3186) - Fix wording issue (#3242) + - Fix missing sender information after edits (#3184) Translations 🗣: - diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt index 32f6b94cd8..4a6462477d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt @@ -21,6 +21,7 @@ import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.RelationType import org.matrix.android.sdk.api.session.events.model.getRelationContent +import org.matrix.android.sdk.api.session.events.model.isEdition import org.matrix.android.sdk.api.session.events.model.isReply import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.room.model.EventAnnotationsSummary @@ -151,6 +152,10 @@ fun TimelineEvent.isReply(): Boolean { return root.isReply() } +fun TimelineEvent.isEdition(): Boolean { + return root.isEdition() +} + fun TimelineEvent.getTextEditableContent(): String? { val lastContent = getLastMessageContent() return if (isReply()) { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt index b1e438dff1..124b196f72 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt @@ -39,6 +39,7 @@ import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited +import org.matrix.android.sdk.api.session.room.timeline.isEdition import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent import javax.inject.Inject @@ -69,6 +70,7 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses || nextEvent.root.getClearType() !in listOf(EventType.MESSAGE, EventType.STICKER, EventType.ENCRYPTED) || isNextMessageReceivedMoreThanOneHourAgo || isTileTypeMessage(nextEvent) + || nextEvent.isEdition() val time = dateFormatter.format(event.root.originServerTs, DateFormatKind.MESSAGE_SIMPLE) val e2eDecoration = getE2EDecoration(event)