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