mirror of
https://github.com/FossifyOrg/Contacts.git
synced 2026-02-02 19:52:24 -05:00
Fix delete logic in contact view and contact list if contact merging is disabled
This commit is contained in:
@@ -114,7 +114,7 @@ class ViewContactActivity : ContactActivity() {
|
||||
}
|
||||
|
||||
findItem(R.id.delete).setOnMenuItemClickListener {
|
||||
deleteContactFromAllSources()
|
||||
deleteContactWithMergeLogic()
|
||||
true
|
||||
}
|
||||
|
||||
@@ -838,8 +838,8 @@ class ViewContactActivity : ContactActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteContactFromAllSources() {
|
||||
val addition = if (binding.contactSourcesHolder.childCount > 1) {
|
||||
private fun deleteContactWithMergeLogic() {
|
||||
val addition = if (binding.contactSourcesHolder.childCount > 1 && mergeDuplicate) {
|
||||
"\n\n${getString(R.string.delete_from_all_sources)}"
|
||||
} else {
|
||||
""
|
||||
@@ -848,7 +848,7 @@ class ViewContactActivity : ContactActivity() {
|
||||
val message = "${getString(org.fossify.commons.R.string.proceed_with_deletion)}$addition"
|
||||
ConfirmationDialog(this, message) {
|
||||
if (contact != null) {
|
||||
ContactsHelper(this).deleteContact(contact!!, true) {
|
||||
ContactsHelper(this).deleteContact(contact!!, mergeDuplicate) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,13 +224,11 @@ class ContactsAdapter(
|
||||
|
||||
ContactsHelper(activity).getContacts(true) { allContacts ->
|
||||
ensureBackgroundThread {
|
||||
contactsToRemove.forEach {
|
||||
val contactToRemove = it
|
||||
val duplicates = allContacts.filter { it.id != contactToRemove.id && it.getHashToCompare() == contactToRemove.getHashToCompare() }
|
||||
.toMutableList() as ArrayList<Contact>
|
||||
duplicates.add(contactToRemove)
|
||||
ContactsHelper(activity).deleteContacts(duplicates)
|
||||
}
|
||||
ContactsHelper(activity).deleteContacts(contactsToRemove
|
||||
.flatMap { contactToRemove -> allContacts.filter {
|
||||
(config.mergeDuplicateContacts || it.id == contactToRemove.id) && (it.getHashToCompare() == contactToRemove.getHashToCompare())
|
||||
} }
|
||||
.toMutableList() as ArrayList<Contact>)
|
||||
|
||||
activity.runOnUiThread {
|
||||
if (contactItems.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user