crashfix: thread.uniqueId is sometimes nil in production

fail early and print diagnostics

// FREEBIE
This commit is contained in:
Michael Kirk 2017-08-31 12:31:13 -04:00
parent bb8f6c1b73
commit 2cd2596ddc
2 changed files with 16 additions and 2 deletions

View File

@ -487,8 +487,17 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
_callOnOpen = callOnViewAppearing;
[self.uiDatabaseConnection beginLongLivedReadTransaction];
self.messageMappings =
[[YapDatabaseViewMappings alloc] initWithGroups:@[ thread.uniqueId ] view:TSMessageDatabaseViewExtensionName];
if (thread.uniqueId.length > 0) {
self.messageMappings = [[YapDatabaseViewMappings alloc] initWithGroups:@[ thread.uniqueId ]
view:TSMessageDatabaseViewExtensionName];
} else {
OWSFail(@"uniqueId unexpectedly empty for thread: %@", thread);
self.messageMappings =
[[YapDatabaseViewMappings alloc] initWithGroups:@[] view:TSMessageDatabaseViewExtensionName];
return;
}
// We need to impose the range restrictions on the mappings immediately to avoid
// doing a great deal of unnecessary work and causing a perf hotspot.
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {

View File

@ -726,6 +726,11 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
keyboardOnViewAppearing:(BOOL)keyboardOnViewAppearing
callOnViewAppearing:(BOOL)callOnViewAppearing
{
if (thread == nil) {
OWSFail(@"Thread unexpectedly nil");
return;
}
// We do this synchronously if we're already on the main thread.
DispatchMainThreadSafe(^{
MessagesViewController *mvc = [[MessagesViewController alloc] initWithNibName:@"MessagesViewController"