From a9b4b06c8f058c03d6689ef521efb77ed4bad453 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 17 Oct 2018 10:43:31 -0400 Subject: [PATCH] Retain code verification promise. --- .../CodeVerificationViewController.m | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m b/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m index 5ddc42e25..35c9aa5e5 100644 --- a/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m +++ b/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m @@ -281,39 +281,39 @@ NS_ASSUME_NONNULL_BEGIN [self startActivityIndicator]; OWSProdInfo([OWSAnalyticsEvents registrationRegisteringCode]); __weak CodeVerificationViewController *weakSelf = self; - [self.accountManager registerWithVerificationCode:[self validationCodeFromTextField] pin:nil] - .then(^{ - OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]); - - OWSLogInfo(@"Successfully registered Signal account."); - dispatch_async(dispatch_get_main_queue(), ^{ - [weakSelf stopActivityIndicator]; - [weakSelf verificationWasCompleted]; - }); - }) - .catch(^(NSError *error) { - OWSLogError(@"error: %@, %@, %zd", [error class], error.domain, error.code); - OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]); - OWSLogError(@"error verifying challenge: %@", error); - dispatch_async(dispatch_get_main_queue(), ^{ - [weakSelf stopActivityIndicator]; - - if ([error.domain isEqualToString:OWSSignalServiceKitErrorDomain] - && error.code == OWSErrorCodeRegistrationMissing2FAPIN) { - CodeVerificationViewController *strongSelf = weakSelf; - if (!strongSelf) { - return; + [[self.accountManager registerWithVerificationCode:[self validationCodeFromTextField] pin:nil] + .then(^{ + OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]); + + OWSLogInfo(@"Successfully registered Signal account."); + dispatch_async(dispatch_get_main_queue(), ^{ + [weakSelf stopActivityIndicator]; + [weakSelf verificationWasCompleted]; + }); + }) + .catch(^(NSError *error) { + OWSLogError(@"error: %@, %@, %zd", [error class], error.domain, error.code); + OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]); + OWSLogError(@"error verifying challenge: %@", error); + dispatch_async(dispatch_get_main_queue(), ^{ + [weakSelf stopActivityIndicator]; + + if ([error.domain isEqualToString:OWSSignalServiceKitErrorDomain] + && error.code == OWSErrorCodeRegistrationMissing2FAPIN) { + CodeVerificationViewController *strongSelf = weakSelf; + if (!strongSelf) { + return; + } + OWSLogInfo(@"Showing 2FA registration view."); + OWS2FARegistrationViewController *viewController = [OWS2FARegistrationViewController new]; + viewController.verificationCode = strongSelf.validationCodeFromTextField; + [strongSelf.navigationController pushViewController:viewController animated:YES]; + } else { + [weakSelf presentAlertWithVerificationError:error]; + [weakSelf.challengeTextField becomeFirstResponder]; } - OWSLogInfo(@"Showing 2FA registration view."); - OWS2FARegistrationViewController *viewController = [OWS2FARegistrationViewController new]; - viewController.verificationCode = strongSelf.validationCodeFromTextField; - [strongSelf.navigationController pushViewController:viewController animated:YES]; - } else { - [weakSelf presentAlertWithVerificationError:error]; - [weakSelf.challengeTextField becomeFirstResponder]; - } - }); - }); + }); + }) retainUntilComplete]; } - (void)verificationWasCompleted