Fix overzealous failure when user has no Signal contacts

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 90430c75c0
commit ab1190222b

@ -319,12 +319,22 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
[[ContactsUpdater sharedUpdater] lookupIdentifiers:possiblePhoneNumbers
success:^(NSArray<SignalRecipient *> *recipients) {
OWSAssertIsOnMainThread();
OWSAssert(recipients.count > 0);
if (modalActivityIndicator.wasCancelled) {
return;
}
if (recipients.count == 0) {
[modalActivityIndicator
dismissViewControllerAnimated:NO
completion:^{
NSError *error
= OWSErrorMakeNoSuchSignalRecipientError();
[OWSAlerts showErrorAlertWithMessage:
error.localizedDescription];
}];
return;
}
NSString *recipientId = recipients[0].uniqueId;
[modalActivityIndicator
dismissViewControllerAnimated:NO

@ -10,15 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (instancetype)sharedUpdater;
// This asynchronously tries to verify whether or not a contact id
// corresponds to a service account.
//
// The failure callback is invoked if the lookup fails _or_ if the
// contact id doesn't correspond to an account.
- (void)lookupIdentifier:(NSString *)identifier
success:(void (^)(SignalRecipient *recipient))success
failure:(void (^)(NSError *error))failure;
// This asynchronously tries to verify whether or not a group of possible
// contact ids correspond to service accounts.
//

@ -20,7 +20,6 @@ NS_ASSUME_NONNULL_BEGIN
@end
@implementation ContactsUpdater
+ (instancetype)sharedUpdater {
@ -48,34 +47,6 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (void)lookupIdentifier:(NSString *)recipientId
success:(void (^)(SignalRecipient *recipient))success
failure:(void (^)(NSError *error))failure
{
OWSAssert(recipientId.length > 0);
// This should never happen according to nullability annotations... but IIRC it does. =/
if (!recipientId) {
OWSFail(@"%@ Cannot lookup nil identifier", self.logTag);
failure(OWSErrorWithCodeDescription(OWSErrorCodeInvalidMethodParameters, @"Cannot lookup nil identifier"));
return;
}
NSSet *recipiendIds = [NSSet setWithObject:recipientId];
[self contactIntersectionWithSet:recipiendIds
success:^(NSSet<SignalRecipient *> *recipients) {
if (recipients.count > 0) {
OWSAssert(recipients.count == 1);
SignalRecipient *recipient = recipients.allObjects.firstObject;
success(recipient);
} else {
failure(OWSErrorMakeNoSuchSignalRecipientError());
}
}
failure:failure];
}
- (void)lookupIdentifiers:(NSArray<NSString *> *)identifiers
success:(void (^)(NSArray<SignalRecipient *> *recipients))success
failure:(void (^)(NSError *error))failure
@ -88,11 +59,11 @@ NS_ASSUME_NONNULL_BEGIN
[self contactIntersectionWithSet:[NSSet setWithArray:identifiers]
success:^(NSSet<SignalRecipient *> *recipients) {
if (recipients.count > 0) {
success(recipients.allObjects);
} else {
failure(OWSErrorMakeNoSuchSignalRecipientError());
if (recipients.count == 0) {
DDLogInfo(
@"%@ in %s no contacts are Signal users", self.logTag, __PRETTY_FUNCTION__);
}
success(recipients.allObjects);
}
failure:failure];
}

Loading…
Cancel
Save