Fix concurrency in contacts updater.

pull/1/head
Matthew Chen 7 years ago
parent 492debce41
commit 9904443fcf

@ -53,19 +53,27 @@ NS_ASSUME_NONNULL_BEGIN
{ {
if (identifiers.count < 1) { if (identifiers.count < 1) {
OWSFail(@"%@ Cannot lookup zero identifiers", self.logTag); OWSFail(@"%@ Cannot lookup zero identifiers", self.logTag);
failure(OWSErrorWithCodeDescription(OWSErrorCodeInvalidMethodParameters, @"Cannot lookup zero identifiers")); dispatch_async(dispatch_get_main_queue(), ^{
failure(
OWSErrorWithCodeDescription(OWSErrorCodeInvalidMethodParameters, @"Cannot lookup zero identifiers"));
});
return; return;
} }
[self contactIntersectionWithSet:[NSSet setWithArray:identifiers] [self contactIntersectionWithSet:[NSSet setWithArray:identifiers]
success:^(NSSet<SignalRecipient *> *recipients) { success:^(NSSet<SignalRecipient *> *recipients) {
if (recipients.count == 0) { if (recipients.count == 0) {
DDLogInfo( DDLogInfo(@"%@ in %s no contacts are Signal users", self.logTag, __PRETTY_FUNCTION__);
@"%@ in %s no contacts are Signal users", self.logTag, __PRETTY_FUNCTION__);
} }
dispatch_async(dispatch_get_main_queue(), ^{
success(recipients.allObjects); success(recipients.allObjects);
});
} }
failure:failure]; failure:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
failure(error);
});
}];
} }
- (void)contactIntersectionWithSet:(NSSet<NSString *> *)recipientIdsToLookup - (void)contactIntersectionWithSet:(NSSet<NSString *> *)recipientIdsToLookup

Loading…
Cancel
Save