From f503d7f93cb7b08d0f785bbd67ebb71af9bd8d6a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 10 Apr 2017 16:25:12 -0400 Subject: [PATCH] Stay scrolled to the bottom during in conversation view during updates. // FREEBIE --- Signal/src/ViewControllers/MessagesViewController.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/MessagesViewController.m b/Signal/src/ViewControllers/MessagesViewController.m index 0a03e7235..c7014bfa4 100644 --- a/Signal/src/ViewControllers/MessagesViewController.m +++ b/Signal/src/ViewControllers/MessagesViewController.m @@ -2380,7 +2380,6 @@ typedef enum : NSUInteger { return; } - __block BOOL scrollToBottom = NO; const CGFloat kIsAtBottomTolerancePts = 5; BOOL wasAtBottom = (self.collectionView.contentOffset.y + self.collectionView.bounds.size.height + @@ -2390,7 +2389,12 @@ typedef enum : NSUInteger { // update is a new outgoing message AND we're already scrolled to // the bottom of the conversation, skip the scroll animation. __block BOOL shouldAnimateScrollToBottom = !wasAtBottom; - + // We want to scroll to the bottom if the user: + // + // a) already was at the bottom of the conversation. + // b) is inserting new interactions. + __block BOOL scrollToBottom = wasAtBottom; + [self.collectionView performBatchUpdates:^{ for (YapDatabaseViewRowChange *rowChange in messageRowChanges) { switch (rowChange.type) {