Merge branch 'charlesmchen/newMessageAnimations' into release/2.28.0

pull/1/head
Michael Kirk 7 years ago
commit f81db023f0

@ -508,12 +508,18 @@ NS_ASSUME_NONNULL_BEGIN
[self.bubbleView addPartnerView:shadowView]; [self.bubbleView addPartnerView:shadowView];
[self.bubbleView addPartnerView:clipView]; [self.bubbleView addPartnerView:clipView];
// Prevent the layer from animating changes.
[CATransaction begin];
[CATransaction setDisableActions:YES];
OWSAssert(buttonsView.backgroundColor); OWSAssert(buttonsView.backgroundColor);
shadowView.fillColor = buttonsView.backgroundColor; shadowView.fillColor = buttonsView.backgroundColor;
shadowView.layer.shadowColor = [UIColor blackColor].CGColor; shadowView.layer.shadowColor = [UIColor blackColor].CGColor;
shadowView.layer.shadowOpacity = 0.12f; shadowView.layer.shadowOpacity = 0.12f;
shadowView.layer.shadowOffset = CGSizeZero; shadowView.layer.shadowOffset = CGSizeZero;
shadowView.layer.shadowRadius = 1.f; shadowView.layer.shadowRadius = 1.f;
[CATransaction commit];
} }
- (BOOL)contactShareHasSpacerTop - (BOOL)contactShareHasSpacerTop

@ -3469,8 +3469,8 @@ typedef enum : NSUInteger {
[self updateLastVisibleTimestamp]; [self updateLastVisibleTimestamp];
if (scrollToBottom) { if (scrollToBottom && shouldAnimateUpdates) {
[self scrollToBottomAnimated:shouldAnimateScrollToBottom && shouldAnimateUpdates]; [self scrollToBottomAnimated:shouldAnimateScrollToBottom];
} }
}; };
if (shouldAnimateUpdates) { if (shouldAnimateUpdates) {
@ -3478,6 +3478,9 @@ typedef enum : NSUInteger {
} else { } else {
[UIView performWithoutAnimation:^{ [UIView performWithoutAnimation:^{
[self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion]; [self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion];
if (scrollToBottom) {
[self scrollToBottomAnimated:NO];
}
}]; }];
} }
self.lastReloadDate = [NSDate new]; self.lastReloadDate = [NSDate new];
@ -3489,55 +3492,40 @@ typedef enum : NSUInteger {
OWSAssert(rowChanges); OWSAssert(rowChanges);
// If user sends a new outgoing message, don't animate the change. // If user sends a new outgoing message, don't animate the change.
BOOL isOnlyInsertingNewOutgoingMessages = YES; BOOL isOnlyModifyingLastMessage = YES;
BOOL isOnlyUpdatingLastOutgoingMessage = YES;
NSNumber *_Nullable lastUpdateRow = nil;
NSNumber *_Nullable lastNonUpdateRow = nil;
for (YapDatabaseViewRowChange *rowChange in rowChanges) { for (YapDatabaseViewRowChange *rowChange in rowChanges) {
switch (rowChange.type) { switch (rowChange.type) {
case YapDatabaseViewChangeDelete: case YapDatabaseViewChangeDelete:
isOnlyInsertingNewOutgoingMessages = NO; isOnlyModifyingLastMessage = NO;
isOnlyUpdatingLastOutgoingMessage = NO;
if (!lastNonUpdateRow || lastNonUpdateRow.integerValue < rowChange.indexPath.row) {
lastNonUpdateRow = @(rowChange.indexPath.row);
}
break; break;
case YapDatabaseViewChangeInsert: { case YapDatabaseViewChangeInsert: {
isOnlyUpdatingLastOutgoingMessage = NO;
ConversationViewItem *_Nullable viewItem = [self viewItemForIndex:(NSInteger)rowChange.finalIndex]; ConversationViewItem *_Nullable viewItem = [self viewItemForIndex:(NSInteger)rowChange.finalIndex];
if ([viewItem.interaction isKindOfClass:[TSOutgoingMessage class]] if (([viewItem.interaction isKindOfClass:[TSIncomingMessage class]] ||
[viewItem.interaction isKindOfClass:[TSOutgoingMessage class]])
&& rowChange.finalIndex >= oldViewItemCount) { && rowChange.finalIndex >= oldViewItemCount) {
continue; continue;
} }
if (!lastNonUpdateRow || lastNonUpdateRow.unsignedIntegerValue < rowChange.finalIndex) { isOnlyModifyingLastMessage = NO;
lastNonUpdateRow = @(rowChange.finalIndex);
}
} }
case YapDatabaseViewChangeMove: case YapDatabaseViewChangeMove:
isOnlyInsertingNewOutgoingMessages = NO; isOnlyModifyingLastMessage = NO;
isOnlyUpdatingLastOutgoingMessage = NO;
if (!lastNonUpdateRow || lastNonUpdateRow.integerValue < rowChange.indexPath.row) {
lastNonUpdateRow = @(rowChange.indexPath.row);
}
if (!lastNonUpdateRow || lastNonUpdateRow.unsignedIntegerValue < rowChange.finalIndex) {
lastNonUpdateRow = @(rowChange.finalIndex);
}
break; break;
case YapDatabaseViewChangeUpdate: { case YapDatabaseViewChangeUpdate: {
isOnlyInsertingNewOutgoingMessages = NO; if (rowChange.changes == YapDatabaseViewChangedDependency) {
ConversationViewItem *_Nullable viewItem = [self viewItemForIndex:(NSInteger)rowChange.finalIndex]; continue;
if (![viewItem.interaction isKindOfClass:[TSOutgoingMessage class]]
|| rowChange.indexPath.row != (NSInteger)(oldViewItemCount - 1)) {
isOnlyUpdatingLastOutgoingMessage = NO;
} }
if (!lastUpdateRow || lastUpdateRow.integerValue < rowChange.indexPath.row) { ConversationViewItem *_Nullable viewItem = [self viewItemForIndex:(NSInteger)rowChange.finalIndex];
lastUpdateRow = @(rowChange.indexPath.row); if (([viewItem.interaction isKindOfClass:[TSIncomingMessage class]] ||
[viewItem.interaction isKindOfClass:[TSOutgoingMessage class]])
&& rowChange.finalIndex >= oldViewItemCount) {
continue;
} }
isOnlyModifyingLastMessage = NO;
break; break;
} }
} }
} }
BOOL shouldAnimateRowUpdates = !(isOnlyInsertingNewOutgoingMessages || isOnlyUpdatingLastOutgoingMessage); BOOL shouldAnimateRowUpdates = !isOnlyModifyingLastMessage;
return shouldAnimateRowUpdates; return shouldAnimateRowUpdates;
} }

Loading…
Cancel
Save