Skip to content

Commit

Permalink
Merge pull request #1153 from vector-im/feature/fix_841
Browse files Browse the repository at this point in the history
Fixes #841
  • Loading branch information
BillCarsonFr committed Mar 18, 2020
2 parents 22a5996 + 14acbb2 commit 08cfe79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Improvements 🙌:
- Verification DM / Handle concurrent .start after .ready (#794)

Bugfix 🐛:
-
- Missing avatar/displayname after verification request message (#841)

Translations 🗣:
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
)
},
Expand All @@ -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
}
}
}

0 comments on commit 08cfe79

Please sign in to comment.