|
|
|
@ -281,17 +281,17 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
|
|
|
|
|
#pragma mark - Mark as Read Locally
|
|
|
|
|
|
|
|
|
|
- (void)markAsReadLocallyBeforeTimestamp:(uint64_t)timestamp thread:(TSThread *)thread
|
|
|
|
|
- (void)markAsReadLocallyBeforeSortId:(uint64_t)sortId thread:(TSThread *)thread
|
|
|
|
|
{
|
|
|
|
|
OWSAssertDebug(thread);
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
|
[self markAsReadBeforeTimestamp:timestamp
|
|
|
|
|
thread:thread
|
|
|
|
|
readTimestamp:[NSDate ows_millisecondTimeStamp]
|
|
|
|
|
wasLocal:YES
|
|
|
|
|
transaction:transaction];
|
|
|
|
|
[self markAsReadBeforeSortId:sortId
|
|
|
|
|
thread:thread
|
|
|
|
|
readTimestamp:[NSDate ows_millisecondTimeStamp]
|
|
|
|
|
wasLocal:YES
|
|
|
|
|
transaction:transaction];
|
|
|
|
|
}];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -493,27 +493,23 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
// Always re-mark the message as read to ensure any earlier read time is applied to disappearing messages.
|
|
|
|
|
[message markAsReadAtTimestamp:readTimestamp sendReadReceipt:NO transaction:transaction];
|
|
|
|
|
|
|
|
|
|
// Also mark any messages appearing earlier in the thread as read.
|
|
|
|
|
//
|
|
|
|
|
// Use `timestampForSorting` which reflects local received order, rather than `timestamp`
|
|
|
|
|
// which reflect sender time.
|
|
|
|
|
// MJK FIXME - use sortID
|
|
|
|
|
[self markAsReadBeforeTimestamp:message.timestampForLegacySorting
|
|
|
|
|
thread:[message threadWithTransaction:transaction]
|
|
|
|
|
readTimestamp:readTimestamp
|
|
|
|
|
wasLocal:NO
|
|
|
|
|
transaction:transaction];
|
|
|
|
|
// Also mark any unread messages appearing earlier in the thread as read as well.
|
|
|
|
|
[self markAsReadBeforeSortId:message.sortId
|
|
|
|
|
thread:[message threadWithTransaction:transaction]
|
|
|
|
|
readTimestamp:readTimestamp
|
|
|
|
|
wasLocal:NO
|
|
|
|
|
transaction:transaction];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Mark As Read
|
|
|
|
|
|
|
|
|
|
- (void)markAsReadBeforeTimestamp:(uint64_t)timestamp
|
|
|
|
|
thread:(TSThread *)thread
|
|
|
|
|
readTimestamp:(uint64_t)readTimestamp
|
|
|
|
|
wasLocal:(BOOL)wasLocal
|
|
|
|
|
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
|
|
|
|
- (void)markAsReadBeforeSortId:(uint64_t)sortId
|
|
|
|
|
thread:(TSThread *)thread
|
|
|
|
|
readTimestamp:(uint64_t)readTimestamp
|
|
|
|
|
wasLocal:(BOOL)wasLocal
|
|
|
|
|
transaction:(YapDatabaseReadWriteTransaction *)transaction
|
|
|
|
|
{
|
|
|
|
|
OWSAssertDebug(timestamp > 0);
|
|
|
|
|
OWSAssertDebug(sortId > 0);
|
|
|
|
|
OWSAssertDebug(thread);
|
|
|
|
|
OWSAssertDebug(transaction);
|
|
|
|
|
|
|
|
|
@ -537,8 +533,7 @@ NSString *const OWSReadReceiptManagerAreReadReceiptsEnabled = @"areReadReceiptsE
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
id<OWSReadTracking> possiblyRead = (id<OWSReadTracking>)object;
|
|
|
|
|
// MJK FIXME - use sortId
|
|
|
|
|
if (possiblyRead.timestampForLegacySorting > timestamp) {
|
|
|
|
|
if (possiblyRead.sortId > sortId) {
|
|
|
|
|
*stop = YES;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|