Merge branch 'charlesmchen/modalActivityIndicatorCR'

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

@ -379,20 +379,17 @@
[ModalActivityIndicatorViewController
presentFromViewController:self
canCancel:NO
presentCompletion:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
[TSAccountManager unregisterTextSecureWithSuccess:^{
[Environment resetAppData];
}
failure:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[modalActivityIndicator dismissWithCompletion:^{
[OWSAlerts
showAlertWithTitle:NSLocalizedString(@"UNREGISTER_SIGNAL_FAIL", @"")];
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"UNREGISTER_SIGNAL_FAIL", @"")];
}];
});
}];
});
}];
}

@ -3456,8 +3456,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
[ModalActivityIndicatorViewController
presentFromViewController:self
canCancel:YES
presentCompletion:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
AVAsset *video = [AVAsset assetWithURL:movieURL];
AVAssetExportSession *exportSession =
[AVAssetExportSession exportSessionWithAsset:video
@ -3498,7 +3497,6 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
}];
});
}];
});
}];
}

@ -36,7 +36,7 @@ class ModalActivityIndicatorViewController: OWSViewController {
}
public class func present(fromViewController: UIViewController,
canCancel: Bool, presentCompletion : @escaping (ModalActivityIndicatorViewController) -> Void) {
canCancel: Bool, backgroundBlock : @escaping (ModalActivityIndicatorViewController) -> Void) {
AssertIsOnMainThread()
let view = ModalActivityIndicatorViewController(canCancel:canCancel)
@ -44,7 +44,9 @@ class ModalActivityIndicatorViewController: OWSViewController {
view.modalPresentationStyle = .overFullScreen
fromViewController.present(view,
animated: false) {
presentCompletion(view)
DispatchQueue.global().async {
backgroundBlock(view)
}
}
}

@ -486,7 +486,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
[ModalActivityIndicatorViewController
presentFromViewController:self
canCancel:NO
presentCompletion:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
TSOutgoingMessage *message =
[[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread
@ -495,6 +495,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
// This will save the message.
[message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)];
dispatch_async(dispatch_get_main_queue(), ^{
if (model.groupImage) {
NSData *data = UIImagePNGRepresentation(model.groupImage);
DataSource *_Nullable dataSource =
@ -508,6 +509,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
} else {
[self.messageSender sendMessage:message success:successHandler failure:failureHandler];
}
});
}];
}

@ -310,8 +310,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
[ModalActivityIndicatorViewController
presentFromViewController:self
canCancel:YES
presentCompletion:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) {
[[ContactsUpdater sharedUpdater] lookupIdentifiers:possiblePhoneNumbers
success:^(NSArray<SignalRecipient *> *recipients) {
OWSAssert([NSThread isMainThread]);
@ -336,14 +335,12 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
[modalActivityIndicator
dismissViewControllerAnimated:NO
completion:^{
[OWSAlerts
showAlertWithTitle:
[OWSAlerts showAlertWithTitle:
NSLocalizedString(@"ALERT_ERROR_TITLE",
@"Title for a generic error alert.")
message:error.localizedDescription];
}];
}];
});
}];
} else {
NSString *recipientId = possiblePhoneNumbers[0];

Loading…
Cancel
Save