From 03f598a1309b647a88da95792e95fe62abc10555 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 21 Nov 2018 11:53:45 -0800 Subject: [PATCH] Sketch out the backup restore view. --- .../ViewControllers/ProfileViewController.m | 49 +++++++++---------- .../BackupRestoreViewController.swift | 2 + 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index 48cb042b7..c0dfaef0a 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -383,35 +383,30 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat } // Show an activity indicator to block the UI during the profile upload. - UIAlertController *alertController = [UIAlertController - alertControllerWithTitle:NSLocalizedString(@"PROFILE_VIEW_SAVING", - @"Alert title that indicates the user's profile view is being saved.") - message:nil - preferredStyle:UIAlertControllerStyleAlert]; - - [self presentViewController:alertController - animated:YES - completion:^{ - [OWSProfileManager.sharedManager updateLocalProfileName:normalizedProfileName - avatarImage:self.avatar - success:^{ - [alertController dismissViewControllerAnimated:NO - completion:^{ - [weakSelf updateProfileCompleted]; - }]; - } - failure:^{ - [alertController - dismissViewControllerAnimated:NO - completion:^{ - [OWSAlerts showErrorAlertWithMessage: - NSLocalizedString( + [ModalActivityIndicatorViewController + presentFromViewController:self + canCancel:NO + backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) { + [OWSProfileManager.sharedManager updateLocalProfileName:normalizedProfileName + avatarImage:self.avatar + success:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + [modalActivityIndicator dismissWithCompletion:^{ + [weakSelf updateProfileCompleted]; + }]; + }); + } + failure:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + [modalActivityIndicator dismissWithCompletion:^{ + [OWSAlerts showErrorAlertWithMessage:NSLocalizedString( @"PROFILE_VIEW_ERROR_UPDATE_FAILED", @"Error message shown when a " @"profile update fails.")]; - }]; - }]; - }]; + }]; + }); + }]; + }]; } - (NSString *)normalizedProfileName @@ -450,6 +445,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat - (void)showHomeView { + OWSAssertIsOnMainThread(); OWSLogVerbose(@""); [SignalApp.sharedApp showHomeView]; @@ -457,6 +453,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat - (void)showBackupRestoreView { + OWSAssertIsOnMainThread(); OWSLogVerbose(@""); BackupRestoreViewController *restoreView = [BackupRestoreViewController new]; diff --git a/Signal/src/ViewControllers/Registration/BackupRestoreViewController.swift b/Signal/src/ViewControllers/Registration/BackupRestoreViewController.swift index 15a8de5af..1c3c90d41 100644 --- a/Signal/src/ViewControllers/Registration/BackupRestoreViewController.swift +++ b/Signal/src/ViewControllers/Registration/BackupRestoreViewController.swift @@ -14,6 +14,8 @@ public class BackupRestoreViewController: OWSTableViewController { } override public func loadView() { + super.loadView() + navigationItem.title = NSLocalizedString("SETTINGS_BACKUP", comment: "Label for the backup view in app settings.") navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(didPressCancelButton))