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 @Index var blocked: Boolean = false
var draft: String = "" var draft: String = ""
fun getTitle(): String { fun getTitle() = recipients.joinToString { recipient ->
var title = "" recipient.contact?.name?.takeIf { it.isNotBlank() }
recipients.forEachIndexed { index, recipient -> ?: PhoneNumberUtils.formatNumber(recipient.address, Locale.getDefault().country)
val name = recipient.contact?.name?.takeIf { it.isNotBlank() } ?: recipient.address
title += name ?: PhoneNumberUtils.formatNumber(recipient.address, Locale.getDefault().country)
if (index < recipients.size - 1) {
title += ", "
}
}
return title
} }
} }