diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index 0bbfa9e1d..cc06e1f03 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -432,10 +432,6 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat [self.navigationController popViewControllerAnimated:YES]; break; case ProfileViewMode_Registration: - if (![TSAccountManager sharedInstance].isReregistering) { - [self checkCanImportBackup]; - return; - } [self showHomeView]; break; case ProfileViewMode_UpgradeOrNag: @@ -452,68 +448,6 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat [SignalApp.sharedApp showHomeView]; } -- (void)showBackupRestoreView -{ - OWSAssertIsOnMainThread(); - OWSLogVerbose(@""); - - BackupRestoreViewController *restoreView = [BackupRestoreViewController new]; - [self.navigationController setViewControllers:@[ - restoreView, - ] - animated:YES]; -} - -- (void)checkCanImportBackup -{ - OWSLogVerbose(@""); - - __weak ProfileViewController *weakSelf = self; - [OWSBackup.sharedManager - checkCanImportBackup:^(BOOL value) { - OWSAssertIsOnMainThread(); - - OWSLogInfo(@"has backup available for import? %d", value); - - if (value) { - [OWSBackup.sharedManager setHasPendingRestoreDecision:YES]; - - [weakSelf showBackupRestoreView]; - } else { - [weakSelf showHomeView]; - } - } - failure:^(NSError *error) { - [weakSelf showBackupCheckFailedAlert]; - }]; -} - -- (void)showBackupCheckFailedAlert -{ - OWSLogVerbose(@""); - - __weak ProfileViewController *weakSelf = self; - UIAlertController *controller = [UIAlertController - alertControllerWithTitle:NSLocalizedString(@"CHECK_FOR_BACKUP_FAILED_TITLE", - @"Title for alert shown when the app failed to check for an existing backup.") - message:NSLocalizedString(@"CHECK_FOR_BACKUP_FAILED_MESSAGE", - @"Message for alert shown when the app failed to check for an existing " - @"backup.") - preferredStyle:UIAlertControllerStyleAlert]; - [controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"REGISTER_FAILED_TRY_AGAIN", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [weakSelf checkCanImportBackup]; - }]]; - [controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CHECK_FOR_BACKUP_DO_NOT_RESTORE", - @"The label for the 'do not restore backup' button.") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *action) { - [weakSelf showHomeView]; - }]]; - [self presentViewController:controller animated:YES completion:nil]; -} - #pragma mark - UITextFieldDelegate - (BOOL)textField:(UITextField *)textField diff --git a/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m b/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m index ff3810d5d..b4c5dda71 100644 --- a/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m +++ b/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m @@ -328,10 +328,81 @@ NS_ASSUME_NONNULL_BEGIN } - (void)verificationWasCompleted +{ + if ([TSAccountManager sharedInstance].isReregistering) { + [self showProfileView]; + } else { + [self checkCanImportBackup]; + } +} + +- (void)showProfileView { [ProfileViewController presentForRegistration:self.navigationController]; } +- (void)showBackupRestoreView +{ + OWSAssertIsOnMainThread(); + OWSLogVerbose(@""); + + BackupRestoreViewController *restoreView = [BackupRestoreViewController new]; + [self.navigationController setViewControllers:@[ + restoreView, + ] + animated:YES]; +} + +- (void)checkCanImportBackup +{ + OWSLogVerbose(@""); + + __weak CodeVerificationViewController *weakSelf = self; + [OWSBackup.sharedManager + checkCanImportBackup:^(BOOL value) { + OWSAssertIsOnMainThread(); + + OWSLogInfo(@"has backup available for import? %d", value); + + if (value) { + [OWSBackup.sharedManager setHasPendingRestoreDecision:YES]; + + [weakSelf showBackupRestoreView]; + } else { + [weakSelf showProfileView]; + } + } + failure:^(NSError *error) { + [weakSelf showBackupCheckFailedAlert]; + }]; +} + +- (void)showBackupCheckFailedAlert +{ + OWSLogVerbose(@""); + + __weak CodeVerificationViewController *weakSelf = self; + UIAlertController *controller = [UIAlertController + alertControllerWithTitle:NSLocalizedString(@"CHECK_FOR_BACKUP_FAILED_TITLE", + @"Title for alert shown when the app failed to check for an existing backup.") + message:NSLocalizedString(@"CHECK_FOR_BACKUP_FAILED_MESSAGE", + @"Message for alert shown when the app failed to check for an existing " + @"backup.") + preferredStyle:UIAlertControllerStyleAlert]; + [controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"REGISTER_FAILED_TRY_AGAIN", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [weakSelf checkCanImportBackup]; + }]]; + [controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CHECK_FOR_BACKUP_DO_NOT_RESTORE", + @"The label for the 'do not restore backup' button.") + style:UIAlertActionStyleDestructive + handler:^(UIAlertAction *action) { + [weakSelf showProfileView]; + }]]; + [self presentViewController:controller animated:YES completion:nil]; +} + - (void)presentAlertWithVerificationError:(NSError *)error { UIAlertController *alert;