Be explicit about receivedAt time
We were often using `timestampForLegacySorting`, which is convoluted for when we actually just want received time. In some sense this is a superficial change, but it's part of auditing that we've completed moved away from timestampForLegacySorting.
This commit is contained in:
parent
6bfd0f29ed
commit
3240e0d9d0
|
@ -126,8 +126,7 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
|
|||
{
|
||||
OWSAssertDebug(viewItem);
|
||||
|
||||
// MJK FIXME - use receivedDate for clarity
|
||||
NSDate *date = viewItem.interaction.dateForLegacySorting;
|
||||
NSDate *date = viewItem.interaction.receivedAtDate;
|
||||
NSString *dateString = [DateUtil formatDateForConversationDateBreaks:date].localizedUppercaseString;
|
||||
|
||||
// Update cell to reflect changes in dynamic text.
|
||||
|
|
|
@ -4926,9 +4926,7 @@ typedef enum : NSUInteger {
|
|||
break;
|
||||
}
|
||||
|
||||
// MJK FIXME - should this be sentTime or receivedTime?
|
||||
// we sorted by received time, but we should display sent time
|
||||
uint64_t viewItemTimestamp = viewItem.interaction.timestampForLegacySorting;
|
||||
uint64_t viewItemTimestamp = viewItem.interaction.receivedAtTimestamp;
|
||||
OWSAssertDebug(viewItemTimestamp > 0);
|
||||
|
||||
BOOL shouldShowDate = NO;
|
||||
|
|
|
@ -93,9 +93,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
TSInteraction *interaction,
|
||||
NSUInteger index,
|
||||
BOOL *stop) {
|
||||
// MJK FIXME - use receivedTime?
|
||||
NSTimeInterval ageSeconds = fabs(
|
||||
interaction.dateForLegacySorting.timeIntervalSinceNow);
|
||||
NSTimeInterval ageSeconds
|
||||
= fabs(interaction.receivedAtDate.timeIntervalSinceNow);
|
||||
if (ageSeconds < maxAgeSeconds) {
|
||||
*stop = YES;
|
||||
return;
|
||||
|
|
|
@ -54,8 +54,7 @@ public struct GalleryDate: Hashable, Comparable, Equatable {
|
|||
let month: Int
|
||||
|
||||
init(message: TSMessage) {
|
||||
// MJK FIXME - use `receivedTime` semantics are the same but would be clearer
|
||||
let date = message.dateForLegacySorting()
|
||||
let date = message.receivedAtDate()
|
||||
|
||||
self.year = Calendar.current.component(.year, from: date)
|
||||
self.month = Calendar.current.component(.month, from: date)
|
||||
|
|
|
@ -292,10 +292,9 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
|
|||
rows.append(sentRow)
|
||||
|
||||
if message as? TSIncomingMessage != nil {
|
||||
// MJK FIXME - expose and use `receivedTime`?
|
||||
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_RECEIVED_DATE_TIME",
|
||||
comment: "Label for the 'received date & time' field of the 'message metadata' view."),
|
||||
value: DateUtil.formatPastTimestampRelativeToNow(message.timestampForLegacySorting())))
|
||||
value: DateUtil.formatPastTimestampRelativeToNow(message.receivedAtTimestamp)))
|
||||
}
|
||||
|
||||
rows += addAttachmentMetadataRows()
|
||||
|
|
|
@ -34,6 +34,8 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
|
|||
@property (nonatomic, readonly) TSThread *thread;
|
||||
@property (nonatomic, readonly) uint64_t timestamp;
|
||||
@property (nonatomic, readonly) uint64_t sortId;
|
||||
@property (nonatomic, readonly) uint64_t receivedAtTimestamp;
|
||||
- (NSDate *)receivedAtDate;
|
||||
|
||||
- (OWSInteractionType)interactionType;
|
||||
|
||||
|
|
|
@ -92,6 +92,37 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
|
|||
|
||||
_timestamp = timestamp;
|
||||
_uniqueThreadId = thread.uniqueId;
|
||||
_receivedAtTimestamp = [NSDate ows_millisecondTimeStamp];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithCoder:(NSCoder *)coder
|
||||
{
|
||||
self = [super initWithCoder:coder];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Previously the receivedAtTimestamp field lived on TSMessage, but we've moved it up
|
||||
// to the TSInteraction superclass.
|
||||
if (_receivedAtTimestamp == 0) {
|
||||
// Upgrade from the older "TSMessage.receivedAtDate" and "TSMessage.receivedAt" properties if
|
||||
// necessary.
|
||||
NSDate *receivedAtDate = [coder decodeObjectForKey:@"receivedAtDate"];
|
||||
if (!receivedAtDate) {
|
||||
receivedAtDate = [coder decodeObjectForKey:@"receivedAt"];
|
||||
}
|
||||
|
||||
if (receivedAtDate) {
|
||||
_receivedAtTimestamp = [NSDate ows_millisecondsSince1970ForDate:receivedAtDate];
|
||||
}
|
||||
|
||||
// For TSInteractions which are not TSMessage's, the timestamp *is* the receivedAtTimestamp
|
||||
if (_receivedAtTimestamp == 0) {
|
||||
_receivedAtTimestamp = _timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -126,6 +157,11 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
|
|||
return self.timestamp;
|
||||
}
|
||||
|
||||
- (NSDate *)receivedAtDate
|
||||
{
|
||||
return [NSDate ows_dateWithMillisecondsSince1970:self.receivedAtTimestamp];
|
||||
}
|
||||
|
||||
- (NSComparisonResult)compareForSorting:(TSInteraction *)other
|
||||
{
|
||||
OWSAssertDebug(other);
|
||||
|
|
|
@ -47,14 +47,6 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
*/
|
||||
@property (nonatomic, readonly) NSUInteger schemaVersion;
|
||||
|
||||
// MJK FIXME - update this comment
|
||||
// The timestamp property is populated by the envelope,
|
||||
// which is created by the sender.
|
||||
//
|
||||
// We typically want to order messages locally by when
|
||||
// they were received & decrypted, not by when they were sent.
|
||||
@property (nonatomic) uint64_t receivedAtTimestamp;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
|
@ -83,7 +75,6 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
_expiresInSeconds = expiresInSeconds;
|
||||
_expireStartedAt = expireStartedAt;
|
||||
[self updateExpiresAt];
|
||||
_receivedAtTimestamp = [NSDate ows_millisecondTimeStamp];
|
||||
_quotedMessage = quotedMessage;
|
||||
_contactShare = contactShare;
|
||||
|
||||
|
@ -136,18 +127,6 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
_attachmentIds = [NSMutableArray new];
|
||||
}
|
||||
|
||||
if (_receivedAtTimestamp == 0) {
|
||||
// Upgrade from the older "receivedAtDate" and "receivedAt" properties if
|
||||
// necessary.
|
||||
NSDate *receivedAtDate = [coder decodeObjectForKey:@"receivedAtDate"];
|
||||
if (!receivedAtDate) {
|
||||
receivedAtDate = [coder decodeObjectForKey:@"receivedAt"];
|
||||
}
|
||||
if (receivedAtDate) {
|
||||
_receivedAtTimestamp = [NSDate ows_millisecondsSince1970ForDate:receivedAtDate];
|
||||
}
|
||||
}
|
||||
|
||||
_schemaVersion = OWSMessageSchemaVersion;
|
||||
|
||||
return self;
|
||||
|
|
|
@ -393,8 +393,7 @@ void AssertIsOnDisappearingMessagesQueue()
|
|||
OWSFailDebug(@"starting old timer for message timestamp: %lu", (unsigned long)message.timestamp);
|
||||
|
||||
// We don't know when it was actually read, so assume it was read as soon as it was received.
|
||||
// MJK FIXME - this needs to use sortId
|
||||
uint64_t readTimeBestGuess = message.timestampForLegacySorting;
|
||||
uint64_t readTimeBestGuess = message.receivedAtTimestamp;
|
||||
[self startAnyExpirationForMessage:message expirationStartedAt:readTimeBestGuess transaction:transaction];
|
||||
}
|
||||
transaction:transaction];
|
||||
|
|
Loading…
Reference in New Issue