Fix formatting of senders and receivers

This commit is contained in:
Ensar Sarajčić 2023-07-11 09:55:57 +02:00
parent a5d6e7724c
commit 6fef121599
1 changed files with 14 additions and 2 deletions

View File

@ -45,8 +45,20 @@ class MessageDetailsDialog(val activity: BaseSimpleActivity, val message: Messag
}
private fun Message.getReceiverOrSenderPhoneNumbers(): String {
return participants.joinToString(", ") {
it.phoneNumbers.first().value
return if (isReceivedMessage()) {
formatContactInfo(senderName, senderPhoneNumber)
} else {
participants.joinToString(", ") {
formatContactInfo(it.name, it.phoneNumbers.first().value)
}
}
}
private fun formatContactInfo(name: String, phoneNumber: String): String {
return if (name != phoneNumber) {
"$name ($phoneNumber)"
} else {
phoneNumber
}
}