From da335a8401d99d97fd55496fbb3aaf2af99632df Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Mon, 23 Aug 2021 11:10:45 +1000 Subject: [PATCH] clean --- Session/Conversations/ConversationViewModel.m | 4 +-- .../Messages/Signal/TSIncomingMessage.h | 2 -- .../Messages/Signal/TSInteraction.h | 5 ++-- .../Messages/Signal/TSInteraction.m | 25 ++++++------------- .../Pollers/OpenGroupPollerV2.swift | 1 - 5 files changed, 11 insertions(+), 26 deletions(-) diff --git a/Session/Conversations/ConversationViewModel.m b/Session/Conversations/ConversationViewModel.m index efcd2cee8..2d63d03b0 100644 --- a/Session/Conversations/ConversationViewModel.m +++ b/Session/Conversations/ConversationViewModel.m @@ -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; diff --git a/SessionMessagingKit/Messages/Signal/TSIncomingMessage.h b/SessionMessagingKit/Messages/Signal/TSIncomingMessage.h index 59c11e6fe..762d0b60d 100644 --- a/SessionMessagingKit/Messages/Signal/TSIncomingMessage.h +++ b/SessionMessagingKit/Messages/Signal/TSIncomingMessage.h @@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN @interface TSIncomingMessage : TSMessage -@property (nonatomic, readonly, nullable) NSNumber *serverTimestamp; - @property (nonatomic, readonly) BOOL wasReceivedByUD; @property (nonatomic, readonly) BOOL isUserMentioned; diff --git a/SessionMessagingKit/Messages/Signal/TSInteraction.h b/SessionMessagingKit/Messages/Signal/TSInteraction.h index 4af4ce1cf..e6b77faf3 100644 --- a/SessionMessagingKit/Messages/Signal/TSInteraction.h +++ b/SessionMessagingKit/Messages/Signal/TSInteraction.h @@ -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 diff --git a/SessionMessagingKit/Messages/Signal/TSInteraction.m b/SessionMessagingKit/Messages/Signal/TSInteraction.m index e6d1a6a93..f3522712d 100644 --- a/SessionMessagingKit/Messages/Signal/TSInteraction.m +++ b/SessionMessagingKit/Messages/Signal/TSInteraction.m @@ -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 diff --git a/SessionMessagingKit/Sending & Receiving/Pollers/OpenGroupPollerV2.swift b/SessionMessagingKit/Sending & Receiving/Pollers/OpenGroupPollerV2.swift index 946a564d7..d5eee9ad1 100644 --- a/SessionMessagingKit/Sending & Receiving/Pollers/OpenGroupPollerV2.swift +++ b/SessionMessagingKit/Sending & Receiving/Pollers/OpenGroupPollerV2.swift @@ -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)