From 9efe1377a242b1dd1ce55fbe6c01a215d4e86812 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 24 Jan 2019 10:38:30 -0500 Subject: [PATCH] Refine invalidation of conversation view layout. --- .../ConversationView/ConversationViewLayout.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m index 55235ffd5..ddfb470e8 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "ConversationViewLayout.h" @@ -10,6 +10,7 @@ NS_ASSUME_NONNULL_BEGIN @interface ConversationViewLayout () +@property (nonatomic) CGFloat lastViewWidth; @property (nonatomic) CGSize contentSize; @property (nonatomic, readonly) NSMutableDictionary *itemAttributesMap; @@ -66,6 +67,7 @@ NS_ASSUME_NONNULL_BEGIN self.contentSize = CGSizeZero; [self.itemAttributesMap removeAllObjects]; self.hasLayout = NO; + self.lastViewWidth = 0.f; } - (void)prepareLayout @@ -135,6 +137,7 @@ NS_ASSUME_NONNULL_BEGIN contentBottom += self.conversationStyle.contentMarginBottom; self.contentSize = CGSizeMake(viewWidth, contentBottom); + self.lastViewWidth = viewWidth; } - (nullable NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect @@ -160,7 +163,7 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { - return self.collectionView.bounds.size.width != newBounds.size.width; + return self.lastViewWidth != newBounds.size.width; } @end