From 89d29b49a36257fe8835c416ef77a403a8f69db7 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 23 Oct 2020 12:20:21 -0700 Subject: [PATCH] Conversation reducer: sort by received_at then sent_at like Backbone --- ts/state/ducks/conversations.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 08fb2870a2d..fafd493cf7b 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -97,6 +97,7 @@ export type MessageType = { | 'call-history'; quote?: { author: string }; received_at: number; + sent_at?: number; hasSignalAccount?: boolean; bodyPending?: boolean; attachments: Array; @@ -829,7 +830,11 @@ export function reducer( ? existingConversation.resetCounter + 1 : 0; - const sorted = orderBy(messages, ['received_at'], ['ASC']); + const sorted = orderBy( + messages, + ['received_at', 'sent_at'], + ['ASC', 'ASC'] + ); const messageIds = sorted.map(message => message.id); const lookup = fromPairs(messages.map(message => [message.id, message])); @@ -1071,7 +1076,11 @@ export function reducer( lookup[message.id] = message; }); - const sorted = orderBy(values(lookup), ['received_at'], ['ASC']); + const sorted = orderBy( + values(lookup), + ['received_at', 'sent_at'], + ['ASC', 'ASC'] + ); const messageIds = sorted.map(message => message.id); const first = sorted[0];