Skip to content

Commit

Permalink
Only display contacts that have a phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
hubert3 authored and FredericJacobs committed Aug 2, 2014
1 parent 5ac7acf commit a4eb34b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Signal/src/contact/ContactsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,24 @@ -(NSArray*) getContactsFromAddressBook:(ABAddressBookRef)addressBook {

NSArray *sortedPeople = (__bridge_transfer NSArray *)allPeopleMutable;

NSPredicate* predicate = [NSPredicate predicateWithBlock: ^BOOL(id record, NSDictionary *bindings) {
ABMultiValueRef phoneNumbers = ABRecordCopyValue( (__bridge ABRecordRef)record, kABPersonPhoneProperty);
BOOL result = NO;

for (CFIndex i = 0; i < ABMultiValueGetCount(phoneNumbers); i++) {
NSString* phoneNumber = (__bridge_transfer NSString*) ABMultiValueCopyValueAtIndex(phoneNumbers, i);
if ([phoneNumber length]>0) {
result = YES;
break;
}
}
CFRelease(phoneNumbers);
return result;
}];
CFRelease(allPeople);
NSArray* filteredContacts = [sortedPeople filteredArrayUsingPredicate:predicate];

return [sortedPeople map:^id(id item) {
return [filteredContacts map:^id(id item) {
return [self contactForRecord:(__bridge ABRecordRef)item];
}];
}
Expand Down

1 comment on commit a4eb34b

@WhisperBTC
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! BitHub has sent payment of $14.63USD for this commit.

Please sign in to comment.