Deduplicate users in contact view helper.

This commit is contained in:
Matthew Chen 2020-08-11 15:51:53 -03:00
parent be1e765e77
commit 2bb22d344e

View File

@ -250,7 +250,15 @@ NS_ASSUME_NONNULL_BEGIN
[accountsToProcess addObject:[[SignalAccount alloc] initWithSignalServiceAddress:address]];
}
NSMutableSet<SignalServiceAddress *> *addressSet = [NSMutableSet new];
for (SignalAccount *signalAccount in accountsToProcess) {
if ([addressSet containsObject:signalAccount.recipientAddress]) {
OWSLogVerbose(@"Ignoring duplicate: %@", signalAccount.recipientAddress);
// We prefer the copy from contactsManager which will appear first
// in accountsToProcess; don't overwrite it.
continue;
}
[addressSet addObject:signalAccount.recipientAddress];
if (signalAccount.recipientPhoneNumber) {
phoneNumberSignalAccountMap[signalAccount.recipientPhoneNumber] = signalAccount;
}