This commit is contained in:
ryanzhao 2021-08-23 11:10:45 +10:00
parent 132ff0416f
commit da335a8401
5 changed files with 11 additions and 26 deletions

View file

@ -1158,7 +1158,7 @@ NS_ASSUME_NONNULL_BEGIN
break;
}
uint64_t viewItemTimestamp = viewItem.interaction.timestampForUI;
uint64_t viewItemTimestamp = viewItem.interaction.timestamp;
OWSAssertDebug(viewItemTimestamp > 0);
BOOL shouldShowDate = NO;
@ -1225,7 +1225,7 @@ NS_ASSUME_NONNULL_BEGIN
NSAttributedString *_Nullable senderName = nil;
OWSInteractionType interactionType = viewItem.interaction.interactionType;
NSString *timestampText = [DateUtil formatTimestampShort:viewItem.interaction.timestampForUI];
NSString *timestampText = [DateUtil formatTimestampShort:viewItem.interaction.timestamp];
if (interactionType == OWSInteractionType_OutgoingMessage) {
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)viewItem.interaction;

View file

@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface TSIncomingMessage : TSMessage <OWSReadTracking>
@property (nonatomic, readonly, nullable) NSNumber *serverTimestamp;
@property (nonatomic, readonly) BOOL wasReceivedByUD;
@property (nonatomic, readonly) BOOL isUserMentioned;

View file

@ -38,9 +38,6 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
@property (nonatomic, readonly) uint64_t timestamp;
@property (nonatomic, readonly) uint64_t sortId;
@property (nonatomic, readonly) uint64_t receivedAtTimestamp;
@property (nonatomic, readonly) BOOL shouldUseServerTime;
- (uint64_t)timestampForUI;
- (NSDate *)dateForUI;
@ -80,6 +77,8 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
- (void)saveNextSortIdWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
NS_SWIFT_NAME(saveNextSortId(transaction:));
- (void)updateTimestamp:(uint64_t)timestamp;
@end
NS_ASSUME_NONNULL_END

View file

@ -165,17 +165,6 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
#pragma mark Date operations
- (uint64_t)timestampForUI
{
// We always want to show the sent timestamp. In the case of one-on-one, closed group and V2 open group messages we get
// this from the protobuf. In the case of V1 open group messages we get it from the envelope in which the message is
// wrapped, which gets parsed to `serverTimestamp` in that case.
if ([self isKindOfClass:TSIncomingMessage.class] && ((TSIncomingMessage *)self).isOpenGroupMessage && ((TSIncomingMessage *)self).serverTimestamp != nil) {
return ((TSIncomingMessage *)self).serverTimestamp.unsignedLongLongValue;
}
return _timestamp;
}
- (uint64_t)timestampForLegacySorting
{
return self.timestamp;
@ -183,7 +172,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
- (NSDate *)dateForUI
{
return [NSDate ows_dateWithMillisecondsSince1970:self.timestampForUI];
return [NSDate ows_dateWithMillisecondsSince1970:self.timestamp];
}
- (NSDate *)receivedAtDate
@ -229,12 +218,6 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
- (uint64_t)sortId
{
// We always want to sort on the sent timestamp. In the case of one-on-one, closed group and V2 open group messages we get
// this from the protobuf. In the case of V1 open group messages we get it from the envelope in which the message is
// wrapped, which gets parsed to `serverTimestamp` in that case.
if ([self isKindOfClass:TSIncomingMessage.class] && ((TSIncomingMessage *)self).isOpenGroupMessage && ((TSIncomingMessage *)self).serverTimestamp != nil) {
return ((TSIncomingMessage *)self).serverTimestamp.unsignedLongLongValue;
}
return self.timestamp;
}
@ -280,6 +263,12 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
[self saveWithTransaction:transaction];
}
- (void)updateTimestamp:(uint64_t)timestamp
{
_timestamp = timestamp;
}
@end
NS_ASSUME_NONNULL_END

View file

@ -73,7 +73,6 @@ public final class OpenGroupPollerV2 : NSObject {
let envelope = SNProtoEnvelope.builder(type: .sessionMessage, timestamp: message.sentTimestamp)
envelope.setContent(data)
envelope.setSource(message.sender!) // Safe because messages with a nil sender are filtered out
envelope.setServerTimestamp(message.sentTimestamp)
do {
let data = try envelope.buildSerializedData()
let (message, proto) = try MessageReceiver.parse(data, openGroupMessageServerID: UInt64(message.serverID!), isRetry: false, using: transaction)