Sort interactions in CVM.

This commit is contained in:
Matthew Chen 2018-12-12 15:24:36 -05:00
parent c04c7e646f
commit 9017c16e7e
1 changed files with 9 additions and 0 deletions

View File

@ -538,6 +538,7 @@ static const int kYapDatabaseRangeMinLength = 0;
[updatedNeighborItemSet addObject:viewItem.itemId];
}
} else {
OWSLogError(@"Update is missing view item");
hasMalformedRowChange = YES;
}
} else if (rowChange.indexPath && rowChange.originalIndex < self.viewItems.count) {
@ -545,6 +546,7 @@ static const int kYapDatabaseRangeMinLength = 0;
// setCellDrawingDependencyOffsets.
OWSAssertDebug(rowChange.changes == YapDatabaseViewChangedDependency);
} else {
OWSFailDebug(@"Update is missing collection key");
hasMalformedRowChange = YES;
}
break;
@ -555,6 +557,7 @@ static const int kYapDatabaseRangeMinLength = 0;
if (collectionKey.key) {
[self.viewItemCache removeObjectForKey:collectionKey.key];
} else {
OWSFailDebug(@"Delete is missing collection key");
hasMalformedRowChange = YES;
}
break;
@ -934,6 +937,12 @@ static const int kYapDatabaseRangeMinLength = 0;
}
}];
// This will usually be redundant, but this will resolve one of the symptoms
// of the "corrupt YDB view" issue caused by multi-process writes.
[viewItems sortUsingComparator:^NSComparisonResult(id<ConversationViewItem> left, id<ConversationViewItem> right) {
return [left.interaction compareForSorting:right.interaction];
}];
// Flag to ensure that we only increment once per launch.
if (hasError) {
OWSLogWarn(@"incrementing version of: %@", TSMessageDatabaseViewExtensionName);