|
|
@ -131,9 +131,9 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
|
|
|
|
|
|
|
|
|
|
|
|
- (void)systemContactsFetcher:(SystemContactsFetcher *)systemsContactsFetcher
|
|
|
|
- (void)systemContactsFetcher:(SystemContactsFetcher *)systemsContactsFetcher
|
|
|
|
updatedContacts:(NSArray<Contact *> *)contacts
|
|
|
|
updatedContacts:(NSArray<Contact *> *)contacts
|
|
|
|
userRequested:(BOOL)userRequested
|
|
|
|
isUserRequested:(BOOL)isUserRequested
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[self updateWithContacts:contacts clearStaleCache:userRequested];
|
|
|
|
[self updateWithContacts:contacts shouldClearStaleCache:isUserRequested];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Intersection
|
|
|
|
#pragma mark - Intersection
|
|
|
@ -191,7 +191,7 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
|
|
|
|
[self.avatarCache removeAllImagesForKey:recipientId];
|
|
|
|
[self.avatarCache removeAllImagesForKey:recipientId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)updateWithContacts:(NSArray<Contact *> *)contacts clearStaleCache:(BOOL)clearStaleCache
|
|
|
|
- (void)updateWithContacts:(NSArray<Contact *> *)contacts shouldClearStaleCache:(BOOL)shouldClearStaleCache
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
NSMutableDictionary<NSString *, Contact *> *allContactsMap = [NSMutableDictionary new];
|
|
|
|
NSMutableDictionary<NSString *, Contact *> *allContactsMap = [NSMutableDictionary new];
|
|
|
@ -211,13 +211,13 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
|
|
|
|
[self.avatarCache removeAllImages];
|
|
|
|
[self.avatarCache removeAllImages];
|
|
|
|
|
|
|
|
|
|
|
|
[self intersectContactsWithCompletion:^(NSError *_Nullable error) {
|
|
|
|
[self intersectContactsWithCompletion:^(NSError *_Nullable error) {
|
|
|
|
[self buildSignalAccountsAndClearStaleCache:clearStaleCache];
|
|
|
|
[self buildSignalAccountsAndClearStaleCache:shouldClearStaleCache];
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)buildSignalAccountsAndClearStaleCache:(BOOL)clearStaleCache;
|
|
|
|
- (void)buildSignalAccountsAndClearStaleCache:(BOOL)shouldClearStaleCache;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
dispatch_async(self.serialQueue, ^{
|
|
|
|
NSMutableArray<SignalAccount *> *signalAccounts = [NSMutableArray new];
|
|
|
|
NSMutableArray<SignalAccount *> *signalAccounts = [NSMutableArray new];
|
|
|
@ -259,12 +259,7 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
|
|
|
|
[SignalAccount
|
|
|
|
[SignalAccount
|
|
|
|
enumerateCollectionObjectsWithTransaction:transaction
|
|
|
|
enumerateCollectionObjectsWithTransaction:transaction
|
|
|
|
usingBlock:^(id _Nonnull object, BOOL *_Nonnull stop) {
|
|
|
|
usingBlock:^(id _Nonnull object, BOOL *_Nonnull stop) {
|
|
|
|
if (![object isKindOfClass:[SignalAccount class]]) {
|
|
|
|
OWSAssert([object isKindOfClass:[SignalAccount class]]);
|
|
|
|
OWSFail(@"%@ Unexpected object in signal account collection: %@",
|
|
|
|
|
|
|
|
self.logTag,
|
|
|
|
|
|
|
|
object);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SignalAccount *oldSignalAccount = (SignalAccount *)object;
|
|
|
|
SignalAccount *oldSignalAccount = (SignalAccount *)object;
|
|
|
|
|
|
|
|
|
|
|
|
oldSignalAccounts[oldSignalAccount.uniqueId] = oldSignalAccount;
|
|
|
|
oldSignalAccounts[oldSignalAccount.uniqueId] = oldSignalAccount;
|
|
|
@ -301,7 +296,7 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
|
|
|
|
[signalAccount saveWithTransaction:transaction];
|
|
|
|
[signalAccount saveWithTransaction:transaction];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (clearStaleCache) {
|
|
|
|
if (shouldClearStaleCache) {
|
|
|
|
DDLogInfo(@"%@ Removing %lu old SignalAccounts.", self.logTag, (unsigned long)oldSignalAccounts.count);
|
|
|
|
DDLogInfo(@"%@ Removing %lu old SignalAccounts.", self.logTag, (unsigned long)oldSignalAccounts.count);
|
|
|
|
for (SignalAccount *signalAccount in oldSignalAccounts.allValues) {
|
|
|
|
for (SignalAccount *signalAccount in oldSignalAccounts.allValues) {
|
|
|
|
DDLogVerbose(@"%@ Removing old SignalAccount: %@", self.logTag, signalAccount);
|
|
|
|
DDLogVerbose(@"%@ Removing old SignalAccount: %@", self.logTag, signalAccount);
|
|
|
|