Fix edge cases in conversation view.

pull/1/head
Matthew Chen 8 years ago
parent 9aeaa00f62
commit 86fdd6dea2

@ -2902,7 +2902,6 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
case YapDatabaseViewChangeDelete: { case YapDatabaseViewChangeDelete: {
DDLogVerbose(@"YapDatabaseViewChangeDelete: %@, %@", rowChange.collectionKey, rowChange.indexPath); DDLogVerbose(@"YapDatabaseViewChangeDelete: %@, %@", rowChange.collectionKey, rowChange.indexPath);
[self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]]; [self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]];
[rowsThatChangedSize removeObject:@(rowChange.indexPath.row)];
YapCollectionKey *collectionKey = rowChange.collectionKey; YapCollectionKey *collectionKey = rowChange.collectionKey;
OWSAssert(collectionKey.key.length > 0); OWSAssert(collectionKey.key.length > 0);
break; break;
@ -2930,6 +2929,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
rowChange.newIndexPath); rowChange.newIndexPath);
[self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]]; [self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]];
[self.collectionView insertItemsAtIndexPaths:@[ rowChange.newIndexPath ]]; [self.collectionView insertItemsAtIndexPaths:@[ rowChange.newIndexPath ]];
[rowsThatChangedSize removeObject:@(rowChange.newIndexPath.row)];
break; break;
} }
case YapDatabaseViewChangeUpdate: { case YapDatabaseViewChangeUpdate: {
@ -2947,7 +2947,9 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
for (NSNumber *row in rowsThatChangedSize) { for (NSNumber *row in rowsThatChangedSize) {
[rowsToReload addObject:[NSIndexPath indexPathForRow:row.integerValue inSection:0]]; [rowsToReload addObject:[NSIndexPath indexPathForRow:row.integerValue inSection:0]];
} }
[self.collectionView reloadItemsAtIndexPaths:rowsToReload]; if (rowsToReload.count > 0) {
[self.collectionView reloadItemsAtIndexPaths:rowsToReload];
}
}; };
void (^batchUpdatesCompletion)(BOOL) = ^(BOOL finished) { void (^batchUpdatesCompletion)(BOOL) = ^(BOOL finished) {
OWSAssert([NSThread isMainThread]); OWSAssert([NSThread isMainThread]);

Loading…
Cancel
Save