Fixed missing contacts after LDAP query

This commit is contained in:
Sylvain Berfini 2022-03-18 09:31:47 +01:00
parent ed9f590f4f
commit f07bc19d5f

View file

@ -34,7 +34,6 @@ import org.linphone.contact.NativeContact
import org.linphone.core.*
import org.linphone.core.tools.Log
import org.linphone.utils.Event
import org.linphone.utils.LinphoneUtils
class ContactsListViewModel : ViewModel() {
val sipContactsSelected = MutableLiveData<Boolean>()
@ -230,15 +229,15 @@ class ContactsListViewModel : ViewModel() {
val address = searchResult.address
if (address != null) {
if (displayName == "") displayName = LinphoneUtils.getDisplayName(address)
if (displayName.isEmpty()) displayName = address.displayName ?: ""
val contact = coreContext.contactsManager.findContactByAddress(address, ignoreLocalContact = true)
if (contact != null) return contact
if (contact != null && (displayName.isEmpty() || contact.fullName == displayName)) return contact
}
val phoneNumber = searchResult.phoneNumber
if (phoneNumber != null) {
if (phoneNumber != null && address?.username != phoneNumber) {
val contact = coreContext.contactsManager.findContactByPhoneNumber(phoneNumber)
if (contact != null && contact.fullName != displayName) return contact
if (contact != null && (displayName.isEmpty() || contact.fullName == displayName)) return contact
}
return null