Clean up ahead of PR.

This commit is contained in:
Matthew Chen 2018-06-20 13:14:21 -04:00
parent 08ca4fdb50
commit 87ea1dcae1
4 changed files with 10 additions and 4 deletions

View file

@ -237,7 +237,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView
let contact = Contact(systemContact: cnContact)
cell.configure(contact: contact, subtitleType: subtitleCellType, showsWhenSelected: self.allowsMultipleSelection, contactsManager: self.contactsManager)
let isSelected = selectedContacts.contains(where: { $0.cnContactId == contact.cnContactId })
let isSelected = selectedContacts.contains(where: { $0.uniqueId == contact.uniqueId })
cell.isSelected = isSelected
// Make sure we preserve selection across tableView.reloadData which happens when toggling between
@ -256,7 +256,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView
let deselectedContact = cell.contact!
selectedContacts = selectedContacts.filter {
return $0.cnContactId != deselectedContact.cnContactId
return $0.uniqueId != deselectedContact.uniqueId
}
}

View file

@ -318,13 +318,13 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
[self.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
for (Contact *contact in contacts) {
NSArray<SignalRecipient *> *signalRecipients = [contact signalRecipientsWithTransaction:transaction];
contactIdToSignalRecipientsMap[contact.cnContactId] = signalRecipients;
contactIdToSignalRecipientsMap[contact.uniqueId] = signalRecipients;
}
}];
NSMutableSet<NSString *> *seenRecipientIds = [NSMutableSet new];
for (Contact *contact in contacts) {
NSArray<SignalRecipient *> *signalRecipients = contactIdToSignalRecipientsMap[contact.cnContactId];
NSArray<SignalRecipient *> *signalRecipients = contactIdToSignalRecipientsMap[contact.uniqueId];
for (SignalRecipient *signalRecipient in [signalRecipients sortedArrayUsingSelector:@selector(compare:)]) {
if ([seenRecipientIds containsObject:signalRecipient.recipientId]) {
DDLogDebug(@"Ignoring duplicate contact: %@, %@", signalRecipient.recipientId, contact.fullName);

View file

@ -26,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly, nonatomic) NSArray<PhoneNumber *> *parsedPhoneNumbers;
@property (readonly, nonatomic) NSArray<NSString *> *userTextPhoneNumbers;
@property (readonly, nonatomic) NSArray<NSString *> *emails;
@property (readonly, nonatomic) NSString *uniqueId;
@property (nonatomic, readonly) BOOL isSignalContact;
@property (nonatomic, readonly) NSString *cnContactId;

View file

@ -117,6 +117,11 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (nullable NSString *)uniqueId
{
return self.cnContactId;
}
+ (nullable Contact *)contactWithVCardData:(NSData *)data
{
CNContact *_Nullable cnContact = [self cnContactWithVCardData:data];