Tweak relative timestamps.

pull/1/head
Matthew Chen 7 years ago
parent 712d6d89e1
commit 41e505fb6f

@ -237,6 +237,8 @@ typedef enum : NSUInteger {
@property (nonatomic, nullable) NSNumber *previousLastTimestamp; @property (nonatomic, nullable) NSNumber *previousLastTimestamp;
@property (nonatomic, nullable) NSNumber *viewHorizonTimestamp; @property (nonatomic, nullable) NSNumber *viewHorizonTimestamp;
@property (nonatomic) ContactShareViewHelper *contactShareViewHelper; @property (nonatomic) ContactShareViewHelper *contactShareViewHelper;
@property (nonatomic) NSTimer *reloadTimer;
@property (nonatomic, nullable) NSDate *lastReloadDate;
@end @end
@ -480,6 +482,39 @@ typedef enum : NSUInteger {
}]; }];
[self updateMessageMappingRangeOptions]; [self updateMessageMappingRangeOptions];
[self updateShouldObserveDBModifications]; [self updateShouldObserveDBModifications];
self.reloadTimer = [NSTimer weakScheduledTimerWithTimeInterval:1.f
target:self
selector:@selector(reloadTimerDidFire)
userInfo:nil
repeats:YES];
}
- (void)dealloc
{
[self.reloadTimer invalidate];
}
- (void)reloadTimerDidFire
{
OWSAssertIsOnMainThread();
if (self.isUserScrolling || !self.isViewCompletelyAppeared || !self.isViewVisible
|| !self.shouldObserveDBModifications || !self.viewHasEverAppeared) {
return;
}
NSDate *now = [NSDate new];
if (self.lastReloadDate) {
NSTimeInterval timeSinceLastReload = [now timeIntervalSinceDate:self.lastReloadDate];
const NSTimeInterval kReloadFrequency = 60.f;
if (timeSinceLastReload < kReloadFrequency) {
return;
}
}
DDLogVerbose(@"%@ reloading conversation view contents.", self.logTag);
[self resetContentAndLayout];
} }
- (BOOL)userLeftGroup - (BOOL)userLeftGroup
@ -795,6 +830,7 @@ typedef enum : NSUInteger {
// Avoid layout corrupt issues and out-of-date message subtitles. // Avoid layout corrupt issues and out-of-date message subtitles.
[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
@ -1669,8 +1705,7 @@ typedef enum : NSUInteger {
self.loadMoreHeader.userInteractionEnabled = showLoadMoreHeader; self.loadMoreHeader.userInteractionEnabled = showLoadMoreHeader;
if (valueChanged) { if (valueChanged) {
[self.collectionView.collectionViewLayout invalidateLayout]; [self resetContentAndLayout];
[self.collectionView reloadData];
} }
} }
@ -3341,6 +3376,7 @@ typedef enum : NSUInteger {
OWSProdLogAndFail(@"%@ hasMalformedRowChange", self.logTag); OWSProdLogAndFail(@"%@ hasMalformedRowChange", self.logTag);
[self reloadViewItems]; [self reloadViewItems];
[self.collectionView reloadData]; [self.collectionView reloadData];
self.lastReloadDate = [NSDate new];
[self updateLastVisibleTimestamp]; [self updateLastVisibleTimestamp];
[self cleanUpUnreadIndicatorIfNecessary]; [self cleanUpUnreadIndicatorIfNecessary];
return; return;
@ -3438,6 +3474,7 @@ typedef enum : NSUInteger {
[self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion]; [self.collectionView performBatchUpdates:batchUpdates completion:batchUpdatesCompletion];
}]; }];
} }
self.lastReloadDate = [NSDate new];
} }
- (BOOL)shouldAnimateRowUpdates:(NSArray<YapDatabaseViewRowChange *> *)rowChanges - (BOOL)shouldAnimateRowUpdates:(NSArray<YapDatabaseViewRowChange *> *)rowChanges
@ -4325,6 +4362,7 @@ typedef enum : NSUInteger {
[self.conversationStyle updateProperties]; [self.conversationStyle updateProperties];
[self.headerView updateAvatar]; [self.headerView updateAvatar];
[self.collectionView reloadData]; [self.collectionView reloadData];
self.lastReloadDate = [NSDate new];
} }
- (void)groupWasUpdated:(TSGroupModel *)groupModel - (void)groupWasUpdated:(TSGroupModel *)groupModel

@ -469,7 +469,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
if (result == nil) { if (result == nil) {
OWSFail(@"%@ Unable to build thumbnail for attachmentId: %@", self.logTag, self.uniqueId); DDLogError(@"%@ Unable to build thumbnail for attachmentId: %@", self.logTag, self.uniqueId);
return; return;
} }

Loading…
Cancel
Save