* Cache cleaning uses YAP notificationsThis way we don't have to worry about cleaning the cache explicitlywhen we do destructive actions.// FREEBIE

* Cache cleaning uses YAP notifications

This way we don't have to worry about cleaning the cache explicitly
when we do destructive actions.

// FREEBIE
pull/1/head
Michael Kirk
parent 95ab3d677c
commit 9f572881f8

@ -1609,9 +1609,12 @@ typedef enum : NSUInteger {
for (YapDatabaseViewRowChange *rowChange in messageRowChanges) { for (YapDatabaseViewRowChange *rowChange in messageRowChanges) {
switch (rowChange.type) { switch (rowChange.type) {
case YapDatabaseViewChangeDelete: { case YapDatabaseViewChangeDelete: {
TSInteraction *interaction = [self interactionAtIndexPath:rowChange.indexPath];
[self.messageAdapterCache removeObjectForKey:interaction.uniqueId];
[self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]]; [self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]];
YapCollectionKey *collectionKey = rowChange.collectionKey;
if (collectionKey.key) {
[self.messageAdapterCache removeObjectForKey:collectionKey.key];
}
break; break;
} }
case YapDatabaseViewChangeInsert: { case YapDatabaseViewChangeInsert: {
@ -1625,13 +1628,15 @@ typedef enum : NSUInteger {
break; break;
} }
case YapDatabaseViewChangeUpdate: { case YapDatabaseViewChangeUpdate: {
YapCollectionKey *collectionKey = rowChange.collectionKey;
if (collectionKey.key) {
[self.messageAdapterCache removeObjectForKey:collectionKey.key];
}
NSMutableArray *rowsToUpdate = [@[ rowChange.indexPath ] mutableCopy]; NSMutableArray *rowsToUpdate = [@[ rowChange.indexPath ] mutableCopy];
if (_lastDeliveredMessageIndexPath) { if (_lastDeliveredMessageIndexPath) {
[rowsToUpdate addObject:_lastDeliveredMessageIndexPath]; [rowsToUpdate addObject:_lastDeliveredMessageIndexPath];
} }
TSInteraction *interaction = [self interactionAtIndexPath:rowChange.indexPath];
[self.messageAdapterCache removeObjectForKey:interaction.uniqueId];
[self.collectionView reloadItemsAtIndexPaths:rowsToUpdate]; [self.collectionView reloadItemsAtIndexPaths:rowsToUpdate];
scrollToBottom = YES; scrollToBottom = YES;
break; break;

Loading…
Cancel
Save