From 80c460553051ed96f8579ab9d08fb01bc5bb6e3c Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Wed, 26 Aug 2020 13:07:12 +1000 Subject: [PATCH] sort with sortId for open groups in TSInteraction --- .../src/Messages/Interactions/TSInteraction.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m index 83af87902..07009a22c 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m @@ -5,6 +5,7 @@ #import "TSInteraction.h" #import "TSDatabaseSecondaryIndexes.h" #import "TSThread.h" +#import "TSGroupThread.h" #import #import @@ -191,6 +192,18 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value) // Loki: Sort the messages by the sender's timestamp (Signal uses sortId) uint64_t sortId1 = self.timestamp; uint64_t sortId2 = other.timestamp; + + // Loki: In open groups, we use the server time to sort the messages + // SortId represents the order that a message is processed + // Since we have sorted the messages in the poller using server time + // SortId can represent the order by server time. + if (self.thread.isGroupThread) { + TSGroupThread *thread = (TSGroupThread *)self.thread; + if (thread.isPublicChat) { + sortId1 = self.sortId; + sortId2 = other.sortId; + } + } if (sortId1 > sortId2) { return NSOrderedDescending;