Use account display name in chat rooms list when displaying last sent message

This commit is contained in:
Sylvain Berfini 2021-03-31 12:06:48 +02:00
parent 773a2ee317
commit 5b529e8e3a

View file

@ -234,9 +234,18 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactViewModelI
private fun formatLastMessage(msg: ChatMessage?): String { private fun formatLastMessage(msg: ChatMessage?): String {
if (msg == null) return "" if (msg == null) return ""
val account = coreContext.core.accountList.find { account ->
account.params.identityAddress?.asStringUriOnly() == msg.fromAddress.asStringUriOnly()
}
val localDisplayName = account?.params?.identityAddress?.displayName
val sender: String = val sender: String =
if (msg.isOutgoing && localDisplayName != null) {
localDisplayName
} else {
coreContext.contactsManager.findContactByAddress(msg.fromAddress)?.fullName coreContext.contactsManager.findContactByAddress(msg.fromAddress)?.fullName
?: LinphoneUtils.getDisplayName(msg.fromAddress) ?: LinphoneUtils.getDisplayName(msg.fromAddress)
}
var body = "" var body = ""
for (content in msg.contents) { for (content in msg.contents) {
if (content.isFile || content.isFileTransfer) body += content.name + " " if (content.isFile || content.isFileTransfer) body += content.name + " "