Merge branch 'charlesmchen/unreadEdgeCases'

pull/1/head
Matthew Chen 7 years ago
commit 5f9f63d897

@ -3413,6 +3413,12 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
if (lastVisibleViewItem) {
uint64_t lastVisibleTimestamp = lastVisibleViewItem.interaction.timestampForSorting;
self.lastVisibleTimestamp = MAX(self.lastVisibleTimestamp, lastVisibleTimestamp);
// If we delete the last unread message (manually or due to disappearing messages)
// we may need to clean up an obsolete unread indicator.
if (lastVisibleViewItem.interaction.interactionType == OWSInteractionType_UnreadIndicator) {
[self ensureDynamicInteractions];
}
}
[self ensureScrollDownButton];

@ -137,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN
dbConnection:(YapDatabaseConnection *)dbConnection
hideUnreadMessagesIndicator:(BOOL)hideUnreadMessagesIndicator
firstUnseenInteractionTimestamp:
(nullable NSNumber *)firstUnseenInteractionTimestampParameter
(nullable NSNumber *)firstUnseenInteractionTimestampParam
maxRangeSize:(int)maxRangeSize
{
OWSAssert(thread);
@ -232,6 +232,21 @@ NS_ASSUME_NONNULL_BEGIN
// have been marked as read.
//
// IFF this variable is non-null, there are unseen messages in the thread.
//
// Make a local copy of this parameter that we can modify.
NSNumber *_Nullable firstUnseenInteractionTimestampParameter = firstUnseenInteractionTimestampParam;
if (firstUnseenInteractionTimestampParameter) {
// Due to disappearing messages or manual deletion,
// firstUnseenInteractionTimestampParameter may refer to an obsolete
// interaction in which case we want to discard it.
TSInteraction *_Nullable lastInteraction =
[[transaction ext:TSMessageDatabaseViewExtensionName] lastObjectInGroup:thread.uniqueId];
if (!lastInteraction
|| lastInteraction.timestampForSorting
< firstUnseenInteractionTimestampParameter.unsignedLongLongValue) {
firstUnseenInteractionTimestampParameter = nil;
}
}
if (firstUnseenInteractionTimestampParameter) {
result.firstUnseenInteractionTimestamp = firstUnseenInteractionTimestampParameter;
} else {

Loading…
Cancel
Save