From 2bb22d344e54ccc68113ce23e58e338cfca9895d Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 11 Aug 2020 15:51:53 -0300 Subject: [PATCH] Deduplicate users in contact view helper. --- SignalMessaging/Views/ContactsViewHelper.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/SignalMessaging/Views/ContactsViewHelper.m b/SignalMessaging/Views/ContactsViewHelper.m index 9c314883cf..4f4af81b61 100644 --- a/SignalMessaging/Views/ContactsViewHelper.m +++ b/SignalMessaging/Views/ContactsViewHelper.m @@ -250,7 +250,15 @@ NS_ASSUME_NONNULL_BEGIN [accountsToProcess addObject:[[SignalAccount alloc] initWithSignalServiceAddress:address]]; } + NSMutableSet *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; }