ConversationView first load avoids redundant layout

We are laying out the collection view, invalidating the layout, and then
laying out the collection view again on first appearance of the
conversation view. This is quite expensive - removing it shaves off
about 30% of load time.

// FREEBIE
This commit is contained in:
Michael Kirk 2017-11-22 11:57:33 -08:00 committed by Michael Kirk
parent 82d13f5514
commit 273063e0aa
2 changed files with 9 additions and 2 deletions

View file

@ -4461,7 +4461,14 @@ typedef enum : NSUInteger {
// Snapshot the scroll state by measuring the "distance from top of view to
// bottom of content"; if the mapping's "window" size grows, it will grow
// _upward_.
CGFloat viewTopToContentBottom = self.safeContentHeight - self.collectionView.contentOffset.y;
CGFloat viewTopToContentBottom = 0;
if ([self.collectionView.collectionViewLayout isKindOfClass:[ConversationViewLayout class]]) {
ConversationViewLayout *conversationViewLayout
= (ConversationViewLayout *)self.collectionView.collectionViewLayout;
if (conversationViewLayout.hasLayout) {
viewTopToContentBottom = self.safeContentHeight - self.collectionView.contentOffset.y;
}
}
NSUInteger oldCellCount = [self.messageMappings numberOfItemsInGroup:self.thread.uniqueId];

View file

@ -37,7 +37,7 @@ typedef NS_ENUM(NSInteger, ConversationViewLayoutAlignment) {
@interface ConversationViewLayout : UICollectionViewLayout
@property (nonatomic, weak) id<ConversationViewLayoutDelegate> delegate;
@property (nonatomic, readonly) BOOL hasLayout;
@property (nonatomic, readonly) int contentWidth;
@end