Update API of RoomLatestEventFormatter.
This commit is contained in:
parent
919b577659
commit
011378aa76
5 changed files with 33 additions and 25 deletions
|
|
@ -59,25 +59,27 @@ class DefaultRoomLatestEventFormatter(
|
|||
private const val MAX_SAFE_LENGTH = 500
|
||||
}
|
||||
|
||||
override fun format(latestEvent: LatestEventValue, isDmRoom: Boolean): CharSequence? {
|
||||
return when (latestEvent) {
|
||||
LatestEventValue.None -> null
|
||||
is LatestEventValue.Local -> formatContent(
|
||||
content = latestEvent.content,
|
||||
isDmRoom = isDmRoom,
|
||||
isOutgoing = true,
|
||||
senderId = latestEvent.senderId,
|
||||
senderDisambiguatedDisplayName = latestEvent.senderProfile.getDisambiguatedDisplayName(latestEvent.senderId)
|
||||
)
|
||||
is LatestEventValue.Remote -> formatContent(
|
||||
content = latestEvent.content,
|
||||
isDmRoom = isDmRoom,
|
||||
isOutgoing = latestEvent.isOwn,
|
||||
senderId = latestEvent.senderId,
|
||||
senderDisambiguatedDisplayName = latestEvent.senderProfile.getDisambiguatedDisplayName(latestEvent.senderId)
|
||||
)
|
||||
}
|
||||
}
|
||||
override fun format(
|
||||
latestEvent: LatestEventValue.Local,
|
||||
isDmRoom: Boolean,
|
||||
): CharSequence? = formatContent(
|
||||
content = latestEvent.content,
|
||||
isDmRoom = isDmRoom,
|
||||
isOutgoing = true,
|
||||
senderId = latestEvent.senderId,
|
||||
senderDisambiguatedDisplayName = latestEvent.senderProfile.getDisambiguatedDisplayName(latestEvent.senderId)
|
||||
)
|
||||
|
||||
override fun format(
|
||||
latestEvent: LatestEventValue.Remote,
|
||||
isDmRoom: Boolean,
|
||||
): CharSequence? = formatContent(
|
||||
content = latestEvent.content,
|
||||
isDmRoom = isDmRoom,
|
||||
isOutgoing = latestEvent.isOwn,
|
||||
senderId = latestEvent.senderId,
|
||||
senderDisambiguatedDisplayName = latestEvent.senderProfile.getDisambiguatedDisplayName(latestEvent.senderId)
|
||||
)
|
||||
|
||||
private fun formatContent(
|
||||
content: EventContent,
|
||||
|
|
|
|||
|
|
@ -929,7 +929,7 @@ class DefaultRoomLatestEventFormatterTest {
|
|||
sentByYou: Boolean,
|
||||
senderDisplayName: String?,
|
||||
content: EventContent,
|
||||
): LatestEventValue {
|
||||
): LatestEventValue.Remote {
|
||||
val sender = if (sentByYou) A_USER_ID else someoneElseId
|
||||
val profile = aProfileDetails(senderDisplayName)
|
||||
return aRemoteLatestEvent(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue