From ab304b0b9f41dd51823d1f229fc4093985ac50c4 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Thu, 4 Mar 2021 14:17:07 +0300 Subject: [PATCH] Do not decorate local echos as sent. --- .../helper/MessageInformationDataFactory.kt | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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 201067e7b4..7f7e03663b 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 @@ -31,6 +31,7 @@ import org.matrix.android.sdk.api.crypto.VerificationState import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.events.model.EventType +import org.matrix.android.sdk.api.session.events.model.LocalEcho import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.room.model.ReferencesAggregatedContent import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent @@ -76,7 +77,9 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses val time = dateFormatter.format(event.root.originServerTs, DateFormatKind.MESSAGE_SIMPLE) val e2eDecoration = getE2EDecoration(event) + // SendState Decoration val isSentByMe = event.root.senderId == session.myUserId + val isLocalEcho = LocalEcho.isLocalEchoId(event.eventId) val sendStateDecoration = if (isSentByMe) { val isMedia = when (event.root.content?.toModel()) { is MessageImageContent, @@ -85,7 +88,12 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses is MessageFileContent -> true else -> false } - getSendStateDecoration(event.root.sendState, prevEvent?.root?.sendState, event.readReceipts.any { it.user.userId != session.myUserId }, isMedia) + getSendStateDecoration( + eventSendState = event.root.sendState, + prevEventSendState = prevEvent?.root?.sendState, + anyReadReceipts = event.readReceipts.any { it.user.userId != session.myUserId }, + isMedia = isMedia, + isLocalEcho = isLocalEcho) } else { SendStateDecoration.NONE } @@ -136,8 +144,14 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses ) } - private fun getSendStateDecoration(eventSendState: SendState, prevEventSendState: SendState?, anyReadReceipts: Boolean, isMedia: Boolean): SendStateDecoration { - return if (eventSendState.isSending()) { + private fun getSendStateDecoration( + eventSendState: SendState, + prevEventSendState: SendState?, + anyReadReceipts: Boolean, + isMedia: Boolean, + isLocalEcho: Boolean + ): SendStateDecoration { + return if (eventSendState.isSending() || (eventSendState.isSent() && isLocalEcho)) { if (isMedia) SendStateDecoration.SENDING_MEDIA else SendStateDecoration.SENDING_NON_MEDIA } else if (eventSendState.hasFailed()) { SendStateDecoration.FAILED