From 709c0f1463d9832bbdb9de9bfd45f30143e66bf0 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 19 Apr 2021 14:56:58 +1000 Subject: [PATCH] Add documentation --- .../Messages/Signal/TSInteraction.m | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/SessionMessagingKit/Messages/Signal/TSInteraction.m b/SessionMessagingKit/Messages/Signal/TSInteraction.m index a1bf68e0c..a23a23ab6 100644 --- a/SessionMessagingKit/Messages/Signal/TSInteraction.m +++ b/SessionMessagingKit/Messages/Signal/TSInteraction.m @@ -169,8 +169,11 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) - (uint64_t)timestampForUI { - if ([self isKindOfClass:TSIncomingMessage.class] && ((TSIncomingMessage *) self).isOpenGroupMessage && ((TSIncomingMessage *) self).serverTimestamp != nil) { - return ((TSIncomingMessage *) self).serverTimestamp.unsignedLongLongValue; + // 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; } @@ -199,7 +202,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) // In open groups messages should be sorted by server timestamp. `sortId` represents the order in which messages // were processed. Since in the open group poller we sort messages by their server timestamp, sorting by `sortId` is // effectively the same as sorting by server timestamp. - // sortId == serverTimestamp for open group messages. + // sortId == serverTimestamp (the sent timestamp) for open group messages. // sortId == timestamp (the sent timestamp) for one-to-one and closed group messages. sortId1 = self.sortId; sortId2 = other.sortId; @@ -228,8 +231,11 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) - (uint64_t)sortId { - if ([self isKindOfClass:TSIncomingMessage.class] && ((TSIncomingMessage *) self).isOpenGroupMessage && ((TSIncomingMessage *) self).serverTimestamp != nil) { - return ((TSIncomingMessage *) self).serverTimestamp.unsignedLongLongValue; + // 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; }