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

View file

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