Apply presentAlert() throughout codebase.

pull/2/head
Matthew Chen 6 years ago
parent 882dd16d7c
commit 908fe1d0c9

@ -434,7 +434,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
if (error) { if (error) {
[fromViewController [fromViewController
dismissViewControllerAnimated:YES dismissViewControllerAnimated:YES
completion:^(void) { completion:^{
OWSLogInfo(@"Sending message failed with error: %@", error); OWSLogInfo(@"Sending message failed with error: %@", error);
[self showSendFailureAlertWithError:error [self showSendFailureAlertWithError:error
message:message message:message
@ -448,11 +448,10 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
}); });
}; };
[fromViewController presentViewController:progressAlert [fromViewController presentAlert:progressAlert
animated:YES completion:^{
completion:^(void) { sendMessageBlock(sendCompletion);
sendMessageBlock(sendCompletion); }];
}];
} }
- (void)showSendFailureAlertWithError:(NSError *)error - (void)showSendFailureAlertWithError:(NSError *)error
@ -503,7 +502,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
OWSFailDebug(@"Untrusted recipient error is missing recipient id."); OWSFailDebug(@"Untrusted recipient error is missing recipient id.");
} }
[fromViewController presentViewController:failureAlert animated:YES completion:nil]; [fromViewController presentAlert:failureAlert];
} else { } else {
// Non-identity failure, e.g. network offline, rate limit // Non-identity failure, e.g. network offline, rate limit
@ -526,7 +525,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
}]; }];
[failureAlert addAction:retryAction]; [failureAlert addAction:retryAction];
[fromViewController presentViewController:failureAlert animated:YES completion:nil]; [fromViewController presentAlert:failureAlert];
} }
} }
@ -597,30 +596,28 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
[progressAlert addAction:progressCancelAction]; [progressAlert addAction:progressCancelAction];
[fromViewController [fromViewController
presentViewController:progressAlert presentAlert:progressAlert
animated:YES completion:^{
completion:^(void) { [self.messageSender sendMessage:message
[self.messageSender sendMessage:message success:^{
success:^(void) { OWSLogInfo(@"Resending attachment succeeded.");
OWSLogInfo(@"Resending attachment succeeded."); dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^(void) { [self.shareViewDelegate shareViewWasCompleted];
[self.shareViewDelegate shareViewWasCompleted]; });
}); }
} failure:^(NSError *error) {
failure:^(NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^(void) { [fromViewController
[fromViewController dismissViewControllerAnimated:YES
dismissViewControllerAnimated:YES completion:^{
completion:^(void) { OWSLogInfo(@"Sending attachment failed with error: %@", error);
OWSLogInfo( [self showSendFailureAlertWithError:error
@"Sending attachment failed with error: %@", error); message:message
[self showSendFailureAlertWithError:error fromViewController:fromViewController];
message:message }];
fromViewController:fromViewController]; });
}]; }];
}); }];
}];
}];
} }
- (void)attachmentUploadProgress:(NSNotification *)notification - (void)attachmentUploadProgress:(NSNotification *)notification

@ -144,6 +144,17 @@ public extension UIViewController {
alert.applyAccessibilityIdentifiers() alert.applyAccessibilityIdentifiers()
}) })
} }
@objc
public func presentAlert(_ alert: UIAlertController, completion: @escaping (() -> Void)) {
self.present(alert,
animated: true,
completion: {
alert.applyAccessibilityIdentifiers()
completion()
})
}
} }
// MARK: - // MARK: -

Loading…
Cancel
Save