mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Avoid double layout in conversation view; but carefully.
This commit is contained in:
parent
273063e0aa
commit
4f520646cc
|
@ -4462,12 +4462,14 @@ typedef enum : NSUInteger {
|
|||
// bottom of content"; if the mapping's "window" size grows, it will grow
|
||||
// _upward_.
|
||||
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;
|
||||
}
|
||||
OWSAssert([self.collectionView.collectionViewLayout isKindOfClass:[ConversationViewLayout class]]);
|
||||
ConversationViewLayout *conversationViewLayout
|
||||
= (ConversationViewLayout *)self.collectionView.collectionViewLayout;
|
||||
// To avoid laying out the collection view during initial view
|
||||
// presentation, don't trigger layout here (via safeContentHeight)
|
||||
// until layout has been done at least once.
|
||||
if (conversationViewLayout.hasEverHadLayout) {
|
||||
viewTopToContentBottom = self.safeContentHeight - self.collectionView.contentOffset.y;
|
||||
}
|
||||
|
||||
NSUInteger oldCellCount = [self.messageMappings numberOfItemsInGroup:self.thread.uniqueId];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
@ -38,6 +38,7 @@ typedef NS_ENUM(NSInteger, ConversationViewLayoutAlignment) {
|
|||
|
||||
@property (nonatomic, weak) id<ConversationViewLayoutDelegate> delegate;
|
||||
@property (nonatomic, readonly) BOOL hasLayout;
|
||||
@property (nonatomic, readonly) BOOL hasEverHadLayout;
|
||||
@property (nonatomic, readonly) int contentWidth;
|
||||
|
||||
@end
|
||||
|
|
|
@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// layout without incurring any of the (great) expense of performing an
|
||||
// unnecessary layout pass.
|
||||
@property (nonatomic) BOOL hasLayout;
|
||||
@property (nonatomic) BOOL hasEverHadLayout;
|
||||
|
||||
@property (nonatomic) int contentWidth;
|
||||
|
||||
|
@ -37,6 +38,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)setHasLayout:(BOOL)hasLayout
|
||||
{
|
||||
_hasLayout = hasLayout;
|
||||
|
||||
if (hasLayout) {
|
||||
self.hasEverHadLayout = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)invalidateLayout
|
||||
{
|
||||
[super invalidateLayout];
|
||||
|
|
Loading…
Reference in a new issue