From 6f5bebedf82c6da567f3d3c856ada1abca2e4fb8 Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 18 Mar 2020 11:53:38 +0100 Subject: [PATCH] Fixes #841 --- .../helper/MessageInformationDataFactory.kt | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt index 2a7261665a..0758e34495 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt @@ -22,7 +22,9 @@ import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.api.session.room.model.ReferencesAggregatedContent +import im.vector.matrix.android.api.session.room.model.message.MessageVerificationRequestContent import im.vector.matrix.android.api.session.room.timeline.TimelineEvent +import im.vector.matrix.android.api.session.room.timeline.getLastMessageContent import im.vector.matrix.android.api.session.room.timeline.hasBeenEdited import im.vector.matrix.android.internal.session.room.VerificationState import im.vector.riotx.core.date.VectorDateFormatter @@ -61,6 +63,7 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses || event.getDisambiguatedDisplayName() != nextEvent?.getDisambiguatedDisplayName() || (nextEvent.root.getClearType() != EventType.MESSAGE && nextEvent.root.getClearType() != EventType.ENCRYPTED) || isNextMessageReceivedMoreThanOneHourAgo + || isTileTypeMessage(nextEvent) val time = dateFormatter.formatMessageHour(date) val avatarUrl = event.senderAvatar @@ -88,7 +91,7 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses myVote = it.aggregatedContent?.myVote, isClosed = it.closedTime ?: Long.MAX_VALUE > System.currentTimeMillis(), votes = it.aggregatedContent?.votes - ?.groupBy({ it.optionIndex }, { it.userId }) + ?.groupBy({ it.optionIndex }, { it.userId }) ?.mapValues { it.value.size } ) }, @@ -111,4 +114,19 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses sentByMe = event.root.senderId == session.myUserId ) } + + /** + * Tiles type message never show the sender information (like verification request), so we should repeat it for next message + * even if same sender + */ + private fun isTileTypeMessage(event: TimelineEvent?): Boolean { + return when (event?.root?.getClearType()) { + EventType.KEY_VERIFICATION_DONE, + EventType.KEY_VERIFICATION_CANCEL -> true + EventType.MESSAGE -> { + event.getLastMessageContent() is MessageVerificationRequestContent + } + else -> false + } + } }