Clean up code for adding new contact to message recipients

This commit is contained in:
Moez Bhatti
2018-04-05 06:22:21 -04:00
parent 28962c5d21
commit e6e55e9113
@@ -206,8 +206,10 @@ class ComposeViewModel(intent: Intent) : QkViewModel<ComposeView, ComposeState>(
.filterNot { contact -> selectedContacts.contains(contact) }
.filter { contact -> contactFilter.filter(contact, query) }
// If the entry is a valid destination, allow it as a recipient
if (PhoneNumberUtils.isWellFormedSmsAddress(query.toString())) {
filteredContacts = listOf(Contact(numbers = RealmList(PhoneNumber(address = query.toString())))) + filteredContacts
val newContact = Contact(numbers = RealmList(PhoneNumber(address = query.toString())))
filteredContacts = listOf(newContact) + filteredContacts
}
filteredContacts