must *always* be in main thread when dismissing view controller. (#1114)

Fixes intermittent crash when uploading new group photos.

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent 5869fb8e06
commit 95ab3d677c

@ -142,59 +142,56 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
inMessage:message
thread:self.thread
success:^{
[self dismissViewControllerAnimated:YES
completion:^{
[Environment messageGroup:self.thread];
}];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES
completion:^{
[Environment messageGroup:self.thread];
}];
});
}
failure:^{
[self
dismissViewControllerAnimated:YES
completion:^{
[[TSStorageManager sharedManager]
.dbConnection
readWriteWithBlock:^(
YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.thread removeWithTransaction:transaction];
}];
SignalAlertView(
NSLocalizedString(@"GROUP_CREATING_FAILED", nil),
NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil));
}];
}];
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES
completion:^{
[TSStorageManager.sharedManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction){
[self.thread removeWithTransaction:transaction];
}];
SignalAlertView(NSLocalizedString(@"GROUP_CREATING_FAILED", nil),
NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil));
}
];
});
}
];
} else {
[[TSMessagesManager sharedManager] sendMessage:message
inThread:self.thread
success:^{
[self dismissViewControllerAnimated:YES
completion:^{
[Environment messageGroup:self.thread];
}];
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES
completion:^{
[Environment messageGroup:self.thread];
}
];
});
}
failure:^{
[self
dismissViewControllerAnimated:YES
completion:^{
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES
completion:^{
[TSStorageManager.sharedManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction){
[self.thread removeWithTransaction:transaction];
}];
SignalAlertView(NSLocalizedString(@"GROUP_CREATING_FAILED", nil),
NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil));
}
];
});
[[TSStorageManager sharedManager]
.dbConnection
readWriteWithBlock:^(
YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.thread removeWithTransaction:transaction];
}];
SignalAlertView(
NSLocalizedString(@"GROUP_CREATING_FAILED", nil),
NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil));
}];
}];
}
];
}
}];
}

Loading…
Cancel
Save