mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-27 10:03:06 +01:00
Fixes #841
This commit is contained in:
parent
56c241c9bd
commit
6f5bebedf8
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user