at deleting a contact delete all duplicates too
This commit is contained in:
parent
797df0a2d7
commit
8fdb6ee0a8
2 changed files with 8 additions and 9 deletions
|
@ -477,7 +477,7 @@ class ViewContactActivity : ContactActivity() {
|
|||
}
|
||||
|
||||
addContactSource(contact!!)
|
||||
ContactsHelper(this).getDuplicatesOfContact(contact!!) { contacts ->
|
||||
ContactsHelper(this).getDuplicatesOfContact(contact!!, false) { contacts ->
|
||||
runOnUiThread {
|
||||
contacts.forEach {
|
||||
addContactSource(it)
|
||||
|
|
|
@ -1524,13 +1524,9 @@ class ContactsHelper(val context: Context) {
|
|||
LocalContactsHelper(context).toggleFavorites(localContacts, addToFavorites)
|
||||
}
|
||||
|
||||
fun deleteContact(contact: Contact) {
|
||||
ensureBackgroundThread {
|
||||
if (contact.isPrivate()) {
|
||||
context.contactsDB.deleteContactId(contact.id)
|
||||
} else {
|
||||
deleteContacts(arrayListOf(contact))
|
||||
}
|
||||
fun deleteContact(originalContact: Contact) {
|
||||
getDuplicatesOfContact(originalContact, true) { contacts ->
|
||||
deleteContacts(contacts)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1562,10 +1558,13 @@ class ContactsHelper(val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
fun getDuplicatesOfContact(contact: Contact, callback: (ArrayList<Contact>) -> Unit) {
|
||||
fun getDuplicatesOfContact(contact: Contact, addOriginal: Boolean, callback: (ArrayList<Contact>) -> Unit) {
|
||||
ensureBackgroundThread {
|
||||
getContacts { contacts ->
|
||||
val duplicates = contacts.filter { it.id != contact.id && it.getHashToCompare() == contact.getHashToCompare() }.toMutableList() as ArrayList<Contact>
|
||||
if (addOriginal) {
|
||||
duplicates.add(contact)
|
||||
}
|
||||
callback(duplicates)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue