Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Contacts.getAll((err, contacts) => {
let contactToDelete = _.find(
contacts,
(contact) => contact.givenName
&& contact.givenName.indexOf(PREFIX) === 0
)
if (!contactToDelete) {
contactToDelete = contacts[0]
}
console.log('attempting to delete', contactToDelete)
Contacts.deleteContact(contactToDelete, (err, data) => {
Contacts.getAll((err, newContactList) => {
console.log('resultant list', newContactList)
invariant(
newContactList.length === contacts.length -1,
'getAll should return one less result'
)
invariant(
!_.find(newContactList, {recordID: contactToDelete.recordID}),
'contact should not longer exist'
)
})
})
})
}
onDelete={() =>
Contacts.deleteContact(contact, () => {
this.loadContacts();
})
}