Merge branch 'charlesmchen/registrationCleanup'

pull/1/head
Matthew Chen 8 years ago
commit efcbd3b3a3

@ -262,13 +262,14 @@ NS_ASSUME_NONNULL_BEGIN
{ {
[self startActivityIndicator]; [self startActivityIndicator];
OWSProdInfo([OWSAnalyticsEvents registrationRegisteringCode]); OWSProdInfo([OWSAnalyticsEvents registrationRegisteringCode]);
__weak CodeVerificationViewController *weakSelf = self;
[self.accountManager registerWithVerificationCode:[self validationCodeFromTextField]] [self.accountManager registerWithVerificationCode:[self validationCodeFromTextField]]
.then(^{ .then(^{
OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]); OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]);
DDLogInfo(@"%@ Successfully registered Signal account.", self.tag); DDLogInfo(@"%@ Successfully registered Signal account.", weakSelf.tag);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self stopActivityIndicator]; [weakSelf stopActivityIndicator];
SignalsViewController *homeView = [SignalsViewController new]; SignalsViewController *homeView = [SignalsViewController new];
homeView.newlyRegisteredUser = YES; homeView.newlyRegisteredUser = YES;
@ -281,10 +282,11 @@ NS_ASSUME_NONNULL_BEGIN
}) })
.catch(^(NSError *_Nonnull error) { .catch(^(NSError *_Nonnull error) {
OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]); OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]);
DDLogError(@"%@ error verifying challenge: %@", self.tag, error); DDLogError(@"%@ error verifying challenge: %@", weakSelf.tag, error);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self stopActivityIndicator]; [weakSelf stopActivityIndicator];
[self presentAlertWithVerificationError:error]; [weakSelf presentAlertWithVerificationError:error];
[weakSelf.challengeTextField becomeFirstResponder];
}); });
}); });
} }
@ -321,7 +323,7 @@ NS_ASSUME_NONNULL_BEGIN
return [self.challengeTextField.text stringByReplacingOccurrencesOfString:@"-" withString:@""]; return [self.challengeTextField.text stringByReplacingOccurrencesOfString:@"-" withString:@""];
} }
#pragma mark - Send codes again #pragma mark - Actions
- (void)sendCodeViaSMSAction:(id)sender { - (void)sendCodeViaSMSAction:(id)sender {
OWSProdInfo([OWSAnalyticsEvents registrationRegisteringRequestedNewCodeBySms]); OWSProdInfo([OWSAnalyticsEvents registrationRegisteringRequestedNewCodeBySms]);
@ -329,16 +331,18 @@ NS_ASSUME_NONNULL_BEGIN
[self enableServerActions:NO]; [self enableServerActions:NO];
[_requestCodeAgainSpinner startAnimating]; [_requestCodeAgainSpinner startAnimating];
__weak CodeVerificationViewController *weakSelf = self;
[TSAccountManager rerequestSMSWithSuccess:^{ [TSAccountManager rerequestSMSWithSuccess:^{
DDLogInfo(@"%@ Successfully requested SMS code", self.tag); DDLogInfo(@"%@ Successfully requested SMS code", weakSelf.tag);
[self enableServerActions:YES]; [weakSelf enableServerActions:YES];
[_requestCodeAgainSpinner stopAnimating]; [weakSelf.requestCodeAgainSpinner stopAnimating];
} }
failure:^(NSError *error) { failure:^(NSError *error) {
DDLogError(@"%@ Failed to request SMS code with error: %@", self.tag, error); DDLogError(@"%@ Failed to request SMS code with error: %@", weakSelf.tag, error);
[self showRegistrationErrorMessage:error]; [weakSelf showRegistrationErrorMessage:error];
[self enableServerActions:YES]; [weakSelf enableServerActions:YES];
[_requestCodeAgainSpinner stopAnimating]; [weakSelf.requestCodeAgainSpinner stopAnimating];
[weakSelf.challengeTextField becomeFirstResponder];
}]; }];
} }
@ -348,17 +352,19 @@ NS_ASSUME_NONNULL_BEGIN
[self enableServerActions:NO]; [self enableServerActions:NO];
[_requestCallSpinner startAnimating]; [_requestCallSpinner startAnimating];
__weak CodeVerificationViewController *weakSelf = self;
[TSAccountManager rerequestVoiceWithSuccess:^{ [TSAccountManager rerequestVoiceWithSuccess:^{
DDLogInfo(@"%@ Successfully requested voice code", self.tag); DDLogInfo(@"%@ Successfully requested voice code", weakSelf.tag);
[self enableServerActions:YES]; [weakSelf enableServerActions:YES];
[_requestCallSpinner stopAnimating]; [weakSelf.requestCallSpinner stopAnimating];
} }
failure:^(NSError *error) { failure:^(NSError *error) {
DDLogError(@"%@ Failed to request voice code with error: %@", self.tag, error); DDLogError(@"%@ Failed to request voice code with error: %@", weakSelf.tag, error);
[self showRegistrationErrorMessage:error]; [weakSelf showRegistrationErrorMessage:error];
[self enableServerActions:YES]; [weakSelf enableServerActions:YES];
[_requestCallSpinner stopAnimating]; [weakSelf.requestCallSpinner stopAnimating];
[weakSelf.challengeTextField becomeFirstResponder];
}]; }];
} }
@ -385,6 +391,7 @@ NS_ASSUME_NONNULL_BEGIN
UITapGestureRecognizer *outsideTabRecognizer = UITapGestureRecognizer *outsideTabRecognizer =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboardFromAppropriateSubView)]; [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboardFromAppropriateSubView)];
[self.view addGestureRecognizer:outsideTabRecognizer]; [self.view addGestureRecognizer:outsideTabRecognizer];
self.view.userInteractionEnabled = YES;
} }
- (void)dismissKeyboardFromAppropriateSubView { - (void)dismissKeyboardFromAppropriateSubView {

@ -61,6 +61,9 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
- (void)createViews - (void)createViews
{ {
self.view.backgroundColor = [UIColor ows_signalBrandBlueColor]; self.view.backgroundColor = [UIColor ows_signalBrandBlueColor];
self.view.userInteractionEnabled = YES;
[self.view
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundTapped:)]];
UIView *header = [UIView new]; UIView *header = [UIView new];
header.backgroundColor = [UIColor ows_signalBrandBlueColor]; header.backgroundColor = [UIColor ows_signalBrandBlueColor];
@ -363,6 +366,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
[weakSelf.activateButton setEnabled:YES]; [weakSelf.activateButton setEnabled:YES];
[weakSelf.spinnerView stopAnimating]; [weakSelf.spinnerView stopAnimating];
[weakSelf.phoneNumberTextField becomeFirstResponder];
} }
smsVerification:YES]; smsVerification:YES];
} }
@ -389,6 +393,13 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
buttonTitle:CommonStrings.dismissButton]; buttonTitle:CommonStrings.dismissButton];
} }
- (void)backgroundTapped:(UIGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateRecognized) {
[self.phoneNumberTextField becomeFirstResponder];
}
}
#pragma mark - CountryCodeViewControllerDelegate #pragma mark - CountryCodeViewControllerDelegate
- (void)countryCodeViewController:(CountryCodeViewController *)vc - (void)countryCodeViewController:(CountryCodeViewController *)vc

Loading…
Cancel
Save