Delay footer collapse in new messages.

This commit is contained in:
Matthew Chen 2018-08-03 10:26:37 -04:00
parent c957578a01
commit 251eef46a2
1 changed files with 16 additions and 3 deletions

View File

@ -235,6 +235,7 @@ typedef enum : NSUInteger {
@property (nonatomic) ContactShareViewHelper *contactShareViewHelper;
@property (nonatomic) NSTimer *reloadTimer;
@property (nonatomic, nullable) NSDate *lastReloadDate;
@property (nonatomic, nullable) NSDate *collapseCutoffDate;
@end
@ -447,6 +448,7 @@ typedef enum : NSUInteger {
// Cache the cell media for ~24 cells.
self.cellMediaCache.countLimit = 24;
_conversationStyle = [[ConversationStyle alloc] initWithThread:thread];
self.collapseCutoffDate = [NSDate new];
// We need to update the "unread indicator" _before_ we determine the initial range
// size, since it depends on where the unread indicator is placed.
@ -818,9 +820,11 @@ typedef enum : NSUInteger {
- (void)resetContentAndLayout
{
// Avoid layout corrupt issues and out-of-date message subtitles.
self.lastReloadDate = [NSDate new];
self.collapseCutoffDate = [NSDate new];
[self reloadViewItems];
[self.collectionView.collectionViewLayout invalidateLayout];
[self.collectionView reloadData];
self.lastReloadDate = [NSDate new];
}
- (void)setUserHasScrolled:(BOOL)userHasScrolled
@ -3384,9 +3388,10 @@ typedef enum : NSUInteger {
// These errors seems to be very rare; they can only be reproduced
// using the more extreme actions in the debug UI.
OWSProdLogAndFail(@"%@ hasMalformedRowChange", self.logTag);
self.lastReloadDate = [NSDate new];
self.collapseCutoffDate = [NSDate new];
[self reloadViewItems];
[self.collectionView reloadData];
self.lastReloadDate = [NSDate new];
[self updateLastVisibleTimestamp];
return;
}
@ -4349,9 +4354,11 @@ typedef enum : NSUInteger {
- (void)conversationColorWasUpdated
{
[self.conversationStyle updateProperties];
self.collapseCutoffDate = [NSDate new];
self.lastReloadDate = [NSDate new];
[self reloadViewItems];
[self.headerView updateAvatar];
[self.collectionView reloadData];
self.lastReloadDate = [NSDate new];
}
- (void)groupWasUpdated:(TSGroupModel *)groupModel
@ -4862,6 +4869,8 @@ typedef enum : NSUInteger {
BOOL shouldShowDateOnNextViewItem = YES;
uint64_t previousViewItemTimestamp = 0;
OWSUnreadIndicator *_Nullable unreadIndicator = self.dynamicInteractions.unreadIndicator;
uint64_t collapseCutoffTimestamp = [NSDate ows_millisecondsSince1970ForDate:self.collapseCutoffDate];
BOOL hasPlacedUnreadIndicator = NO;
for (ConversationViewItem *viewItem in viewItems) {
BOOL canShowDate = NO;
@ -5071,6 +5080,10 @@ typedef enum : NSUInteger {
}
}
if (viewItem.interaction.timestampForSorting > collapseCutoffTimestamp) {
shouldHideFooter = NO;
}
viewItem.isFirstInCluster = isFirstInCluster;
viewItem.isLastInCluster = isLastInCluster;
viewItem.shouldShowSenderAvatar = shouldShowSenderAvatar;