diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 199ed9033..19822ff7a 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -508,12 +508,18 @@ NS_ASSUME_NONNULL_BEGIN [self.bubbleView addPartnerView:shadowView]; [self.bubbleView addPartnerView:clipView]; + // Prevent the layer from animating changes. + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + OWSAssert(buttonsView.backgroundColor); shadowView.fillColor = buttonsView.backgroundColor; shadowView.layer.shadowColor = [UIColor blackColor].CGColor; shadowView.layer.shadowOpacity = 0.12f; shadowView.layer.shadowOffset = CGSizeZero; shadowView.layer.shadowRadius = 1.f; + + [CATransaction commit]; } - (BOOL)contactShareHasSpacerTop diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 35e50c88a..d7fdf01ee 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3468,9 +3468,9 @@ typedef enum : NSUInteger { } [self updateLastVisibleTimestamp]; - - if (scrollToBottom) { - [self scrollToBottomAnimated:shouldAnimateScrollToBottom && shouldAnimateUpdates]; + + if (scrollToBottom && shouldAnimateUpdates) { + [self scrollToBottomAnimated:shouldAnimateScrollToBottom]; } }; if (shouldAnimateUpdates) { @@ -3478,6 +3478,9 @@ typedef enum : NSUInteger { } else { [UIView performWithoutAnimation:^{ [self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion]; + if (scrollToBottom) { + [self scrollToBottomAnimated:NO]; + } }]; } self.lastReloadDate = [NSDate new]; @@ -3489,55 +3492,40 @@ typedef enum : NSUInteger { OWSAssert(rowChanges); // If user sends a new outgoing message, don't animate the change. - BOOL isOnlyInsertingNewOutgoingMessages = YES; - BOOL isOnlyUpdatingLastOutgoingMessage = YES; - NSNumber *_Nullable lastUpdateRow = nil; - NSNumber *_Nullable lastNonUpdateRow = nil; + BOOL isOnlyModifyingLastMessage = YES; for (YapDatabaseViewRowChange *rowChange in rowChanges) { switch (rowChange.type) { case YapDatabaseViewChangeDelete: - isOnlyInsertingNewOutgoingMessages = NO; - isOnlyUpdatingLastOutgoingMessage = NO; - if (!lastNonUpdateRow || lastNonUpdateRow.integerValue < rowChange.indexPath.row) { - lastNonUpdateRow = @(rowChange.indexPath.row); - } + isOnlyModifyingLastMessage = NO; break; case YapDatabaseViewChangeInsert: { - isOnlyUpdatingLastOutgoingMessage = NO; 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) { continue; } - if (!lastNonUpdateRow || lastNonUpdateRow.unsignedIntegerValue < rowChange.finalIndex) { - lastNonUpdateRow = @(rowChange.finalIndex); - } + isOnlyModifyingLastMessage = NO; } case YapDatabaseViewChangeMove: - isOnlyInsertingNewOutgoingMessages = NO; - isOnlyUpdatingLastOutgoingMessage = NO; - if (!lastNonUpdateRow || lastNonUpdateRow.integerValue < rowChange.indexPath.row) { - lastNonUpdateRow = @(rowChange.indexPath.row); - } - if (!lastNonUpdateRow || lastNonUpdateRow.unsignedIntegerValue < rowChange.finalIndex) { - lastNonUpdateRow = @(rowChange.finalIndex); - } + isOnlyModifyingLastMessage = NO; break; case YapDatabaseViewChangeUpdate: { - isOnlyInsertingNewOutgoingMessages = NO; - ConversationViewItem *_Nullable viewItem = [self viewItemForIndex:(NSInteger)rowChange.finalIndex]; - if (![viewItem.interaction isKindOfClass:[TSOutgoingMessage class]] - || rowChange.indexPath.row != (NSInteger)(oldViewItemCount - 1)) { - isOnlyUpdatingLastOutgoingMessage = NO; + if (rowChange.changes == YapDatabaseViewChangedDependency) { + continue; } - if (!lastUpdateRow || lastUpdateRow.integerValue < rowChange.indexPath.row) { - lastUpdateRow = @(rowChange.indexPath.row); + ConversationViewItem *_Nullable viewItem = [self viewItemForIndex:(NSInteger)rowChange.finalIndex]; + if (([viewItem.interaction isKindOfClass:[TSIncomingMessage class]] || + [viewItem.interaction isKindOfClass:[TSOutgoingMessage class]]) + && rowChange.finalIndex >= oldViewItemCount) { + continue; } + isOnlyModifyingLastMessage = NO; break; } } } - BOOL shouldAnimateRowUpdates = !(isOnlyInsertingNewOutgoingMessages || isOnlyUpdatingLastOutgoingMessage); + BOOL shouldAnimateRowUpdates = !isOnlyModifyingLastMessage; return shouldAnimateRowUpdates; }