Merge pull request #1153 from vector-im/feature/fix_841

Fixes #841
This commit is contained in:
Valere 2020-03-18 14:50:56 +01:00 committed by GitHub
commit 08cfe79625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -8,7 +8,7 @@ Improvements 🙌:
- Verification DM / Handle concurrent .start after .ready (#794)
Bugfix 🐛:
-
- Missing avatar/displayname after verification request message (#841)
Translations 🗣:
-

View File

@ -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
}
}
}