Fix null conversation title when phone number can't be formatted

This commit is contained in:
Moez Bhatti
2018-03-14 13:52:14 -07:00
parent 880468031a
commit ce490bf5a5
+4 -11
View File
@@ -33,16 +33,9 @@ open class Conversation : RealmObject() {
@Index var blocked: Boolean = false
var draft: String = ""
fun getTitle(): String {
var title = ""
recipients.forEachIndexed { index, recipient ->
val name = recipient.contact?.name?.takeIf { it.isNotBlank() }
title += name ?: PhoneNumberUtils.formatNumber(recipient.address, Locale.getDefault().country)
if (index < recipients.size - 1) {
title += ", "
}
}
return title
fun getTitle() = recipients.joinToString { recipient ->
recipient.contact?.name?.takeIf { it.isNotBlank() }
?: PhoneNumberUtils.formatNumber(recipient.address, Locale.getDefault().country)
?: recipient.address
}
}