Skip to content

Commit c0f7524

Browse files
authored
fix(contacts): remove 'note' from keysToFetch in delete and isUnified (#326)
Fixes: #324
1 parent dca89bb commit c0f7524

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

packages/contacts/models/contact.ios.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,28 +214,23 @@ export class Contact extends ContactCommon {
214214
}
215215
}
216216
delete() {
217-
var store = new CNContactStore();
218-
var contactRecord;
217+
const store = new CNContactStore();
218+
let contactRecord;
219219

220220
if (this.id && this.id !== '') {
221-
var searchPredicate = CNContact.predicateForContactsWithIdentifiers([this.id]);
222-
var keysToFetch: Array<any> = ['givenName', 'familyName', 'middleName', 'namePrefix', 'nameSuffix', 'phoneticGivenName', 'phoneticMiddleName', 'phoneticFamilyName', 'nickname', 'jobTitle', 'departmentName', 'organizationName', 'note', 'phoneNumbers', 'emailAddresses', 'postalAddresses', 'urlAddresses', 'imageData']; // All Properties that we are changing
223-
var foundContacts = store.unifiedContactsMatchingPredicateKeysToFetchError(searchPredicate, keysToFetch);
221+
const searchPredicate = CNContact.predicateForContactsWithIdentifiers([this.id]);
222+
const keysToFetch: Array<any> = []; // We don't need any fields as we're going to delete it all anyway
223+
const foundContacts = store.unifiedContactsMatchingPredicateKeysToFetchError(searchPredicate, keysToFetch);
224224
if (foundContacts.count > 0) {
225225
contactRecord = foundContacts[0].mutableCopy();
226226
}
227227
}
228228

229229
if (contactRecord) {
230-
var saveRequest = new CNSaveRequest();
230+
const saveRequest = new CNSaveRequest();
231231
saveRequest.deleteContact(contactRecord);
232232

233-
// var error;
234233
store.executeSaveRequestError(saveRequest);
235-
236-
// if (error) {
237-
// throw new Error(error.localizedDescription);
238-
// }
239234
}
240235
}
241236
isUnified() {
@@ -244,7 +239,7 @@ export class Contact extends ContactCommon {
244239

245240
if (this.id && this.id !== '') {
246241
const searchPredicate = CNContact.predicateForContactsWithIdentifiers([this.id]);
247-
const keysToFetch: Array<any> = ['givenName', 'familyName', 'middleName', 'namePrefix', 'nameSuffix', 'phoneticGivenName', 'phoneticMiddleName', 'phoneticFamilyName', 'nickname', 'jobTitle', 'departmentName', 'organizationName', 'note', 'phoneNumbers', 'emailAddresses', 'postalAddresses', 'urlAddresses', 'imageData', 'imageDataAvailable']; // All Properties that we are using in the Model
242+
const keysToFetch: Array<any> = []; // no need to fetch any other data
248243
const foundContacts = store.unifiedContactsMatchingPredicateKeysToFetchError(searchPredicate, keysToFetch);
249244
if (foundContacts.count > 0) {
250245
contactRecord = foundContacts[0];

0 commit comments

Comments
 (0)