sortId vs. Read status

pull/1/head
Michael Kirk 7 years ago
parent 089c4f09ea
commit 90aa593dcd

@ -3934,8 +3934,8 @@ typedef enum : NSUInteger {
// No visible messages yet. New Thread. // No visible messages yet. New Thread.
return; return;
} }
// MJK FIXME - uncomment and implement
// [OWSReadReceiptManager.sharedManager markAsReadLocallyBeforeSortId:lastVisibleSortId thread:self.thread]; [OWSReadReceiptManager.sharedManager markAsReadLocallyBeforeSortId:self.lastVisibleSortId thread:self.thread];
} }
- (void)updateGroupModelTo:(TSGroupModel *)newGroupModel successCompletion:(void (^_Nullable)(void))successCompletion - (void)updateGroupModelTo:(TSGroupModel *)newGroupModel successCompletion:(void (^_Nullable)(void))successCompletion

@ -69,7 +69,7 @@ extern NSString *const kIncomingMessageMarkedAsReadNotification;
// This method can be called from any thread. // This method can be called from any thread.
- (void)messageWasReadLocally:(TSIncomingMessage *)message; - (void)messageWasReadLocally:(TSIncomingMessage *)message;
- (void)markAsReadLocallyBeforeTimestamp:(uint64_t)timestamp thread:(TSThread *)thread; - (void)markAsReadLocallyBeforeSortId:(uint64_t)sortId thread:(TSThread *)thread;
#pragma mark - Settings #pragma mark - Settings

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

@ -16,7 +16,7 @@
@property (nonatomic, readonly, getter=wasRead) BOOL read; @property (nonatomic, readonly, getter=wasRead) BOOL read;
@property (nonatomic, readonly) uint64_t expireStartedAt; @property (nonatomic, readonly) uint64_t expireStartedAt;
@property (nonatomic, readonly) uint64_t timestampForLegacySorting; @property (nonatomic, readonly) uint64_t sortId;
@property (nonatomic, readonly) NSString *uniqueThreadId; @property (nonatomic, readonly) NSString *uniqueThreadId;

Loading…
Cancel
Save