Merge branch 'charlesmchen/pasteLogUpdates'

pull/1/head
Matthew Chen 7 years ago
commit 2e4a655b77

@ -297,7 +297,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
} }
}; };
[self uploadLogsWithSuccess:^(NSURL *url) { [[self sharedManager] uploadLogsWithUIWithSuccess:^(NSURL *url) {
UIAlertController *alert = [UIAlertController UIAlertController *alert = [UIAlertController
alertControllerWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_TITLE", @"Title of the debug log alert.") alertControllerWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_TITLE", @"Title of the debug log alert.")
message:NSLocalizedString(@"DEBUG_LOG_ALERT_MESSAGE", @"Message of the debug log alert.") message:NSLocalizedString(@"DEBUG_LOG_ALERT_MESSAGE", @"Message of the debug log alert.")
@ -357,28 +357,52 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
}]; }];
} }
+ (void)uploadLogsWithSuccess:(nullable UploadDebugLogsSuccess)success - (void)uploadLogsWithUIWithSuccess:(UploadDebugLogsSuccess)successParam {
{ OWSAssertIsOnMainThread();
OWSAssertDebug(success);
[ModalActivityIndicatorViewController
presentFromViewController:UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts
canCancel:YES
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
[self
uploadLogsWithSuccess:^(NSURL *url) {
OWSAssertIsOnMainThread();
if (modalActivityIndicator.wasCancelled) {
return;
}
[modalActivityIndicator dismissWithCompletion:^{
OWSAssertIsOnMainThread();
[[self sharedManager] uploadLogsWithSuccess:success successParam(url);
}];
}
failure:^(NSString *localizedErrorMessage) { failure:^(NSString *localizedErrorMessage) {
OWSAssertIsOnMainThread();
if (modalActivityIndicator.wasCancelled) {
return;
}
[modalActivityIndicator dismissWithCompletion:^{
OWSAssertIsOnMainThread();
[Pastelog showFailureAlertWithMessage:localizedErrorMessage]; [Pastelog showFailureAlertWithMessage:localizedErrorMessage];
}]; }];
}];
}];
} }
- (void)uploadLogsWithSuccess:(nullable UploadDebugLogsSuccess)successParam failure:(UploadDebugLogsFailure)failureParam - (void)uploadLogsWithSuccess:(UploadDebugLogsSuccess)successParam failure:(UploadDebugLogsFailure)failureParam {
{
OWSAssertDebug(successParam); OWSAssertDebug(successParam);
OWSAssertDebug(failureParam); OWSAssertDebug(failureParam);
// Ensure that we call the completions on the main thread. // Ensure that we call the completions on the main thread.
UploadDebugLogsSuccess success = ^(NSURL *url) { UploadDebugLogsSuccess success = ^(NSURL *url) {
if (successParam) {
DispatchMainThreadSafe(^{ DispatchMainThreadSafe(^{
successParam(url); successParam(url);
}); });
}
}; };
UploadDebugLogsFailure failure = ^(NSString *localizedErrorMessage) { UploadDebugLogsFailure failure = ^(NSString *localizedErrorMessage) {
DispatchMainThreadSafe(^{ DispatchMainThreadSafe(^{

Loading…
Cancel
Save