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 inMessage:message
thread:self.thread thread:self.thread
success:^{ success:^{
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{
[Environment messageGroup:self.thread]; [Environment messageGroup:self.thread];
}]; }];
}
});
}
failure:^{ failure:^{
[self dispatch_async(dispatch_get_main_queue(), ^{
dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{
[TSStorageManager.sharedManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction){
[[TSStorageManager sharedManager]
.dbConnection
readWriteWithBlock:^(
YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.thread removeWithTransaction:transaction]; [self.thread removeWithTransaction:transaction];
}]; }];
SignalAlertView( SignalAlertView(NSLocalizedString(@"GROUP_CREATING_FAILED", nil),
NSLocalizedString(@"GROUP_CREATING_FAILED", nil),
NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil)); NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil));
}]; }
];
}]; });
}
];
} else { } else {
[[TSMessagesManager sharedManager] sendMessage:message [[TSMessagesManager sharedManager] sendMessage:message
inThread:self.thread inThread:self.thread
success:^{ success:^{
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{
[Environment messageGroup:self.thread]; [Environment messageGroup:self.thread];
}];
} }
];
});
}
failure:^{ failure:^{
[self dispatch_async(dispatch_get_main_queue(), ^{
dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{
[TSStorageManager.sharedManager.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction){
[[TSStorageManager sharedManager]
.dbConnection
readWriteWithBlock:^(
YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.thread removeWithTransaction:transaction]; [self.thread removeWithTransaction:transaction];
}]; }];
SignalAlertView(NSLocalizedString(@"GROUP_CREATING_FAILED", nil),
SignalAlertView(
NSLocalizedString(@"GROUP_CREATING_FAILED", nil),
NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil)); NSLocalizedString(@"NETWORK_ERROR_RECOVERY", nil));
}]; }
];
});
}]; }
];
} }
}]; }];
} }

Loading…
Cancel
Save