Merge branch 'charlesmchen/deferMessageResizing' into release/2.28.1

pull/1/head
Matthew Chen 6 years ago
commit 89b3ebb72b

@ -228,29 +228,6 @@ NS_ASSUME_NONNULL_BEGIN
// Measure the actual current width, to be safe.
CGFloat timestampLabelWidth = [self.timestampLabel sizeThatFits:CGSizeZero].width;
// Measuring the timestamp label's width is non-trivial since its
// contents can be relative the current time. We avoid having
// message bubbles' "visually vibrate" as their timestamp labels
// vary in width. So we try to leave enough space for all possible
// contents of this label _for the first hour of its lifetime_, when
// the timestamp is particularly volatile.
if ([DateUtil isTimestampFromLastHour:viewItem.interaction.timestamp]) {
// Measure the "now" case.
self.timestampLabel.text = [DateUtil exemplaryNowTimeFormat];
timestampLabelWidth = MAX(timestampLabelWidth, [self.timestampLabel sizeThatFits:CGSizeZero].width);
// Measure the "relative time" case.
// Since this case varies with time, we multiply to leave
// space for the worst case (whose exact value, due to localization,
// is unpredictable).
self.timestampLabel.text = [DateUtil exemplaryMinutesTimeFormat];
timestampLabelWidth = MAX(timestampLabelWidth,
[self.timestampLabel sizeThatFits:CGSizeZero].width + self.timestampLabel.font.lineHeight * 0.5f);
// Re-configure the labels with the current appropriate value in case
// we are configuring this view for display.
[self configureLabelsWithConversationViewItem:viewItem];
}
result.width = timestampLabelWidth;
if (viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage) {
if (![self isFailedOutgoingMessage:viewItem]) {

@ -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
@ -722,6 +723,8 @@ typedef enum : NSUInteger {
[self updateBarButtonItems];
[self updateNavigationTitle];
[self resetContentAndLayout];
// We want to set the initial scroll state the first time we enter the view.
if (!self.viewHasEverAppeared) {
[self scrollToDefaultPosition];
@ -818,9 +821,10 @@ typedef enum : NSUInteger {
- (void)resetContentAndLayout
{
// Avoid layout corrupt issues and out-of-date message subtitles.
self.lastReloadDate = [NSDate new];
[self reloadViewItems];
[self.collectionView.collectionViewLayout invalidateLayout];
[self.collectionView reloadData];
self.lastReloadDate = [NSDate new];
}
- (void)setUserHasScrolled:(BOOL)userHasScrolled
@ -3384,10 +3388,9 @@ 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 reloadViewItems];
[self.collectionView reloadData];
self.lastReloadDate = [NSDate new];
[self resetContentAndLayout];
[self updateLastVisibleTimestamp];
[self scrollToBottomAnimated:NO];
return;
}
@ -4350,8 +4353,7 @@ typedef enum : NSUInteger {
{
[self.conversationStyle updateProperties];
[self.headerView updateAvatar];
[self.collectionView reloadData];
self.lastReloadDate = [NSDate new];
[self resetContentAndLayout];
}
- (void)groupWasUpdated:(TSGroupModel *)groupModel
@ -4818,6 +4820,8 @@ typedef enum : NSUInteger {
// cell view models.
- (void)reloadViewItems
{
self.collapseCutoffDate = [NSDate new];
NSMutableArray<ConversationViewItem *> *viewItems = [NSMutableArray new];
NSMutableDictionary<NSString *, ConversationViewItem *> *viewItemCache = [NSMutableDictionary new];
@ -4862,6 +4866,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 +5077,10 @@ typedef enum : NSUInteger {
}
}
if (viewItem.interaction.timestampForSorting > collapseCutoffTimestamp) {
shouldHideFooter = NO;
}
viewItem.isFirstInCluster = isFirstInCluster;
viewItem.isLastInCluster = isLastInCluster;
viewItem.shouldShowSenderAvatar = shouldShowSenderAvatar;

Loading…
Cancel
Save