diff --git a/packages/message-sdk/src/components/MessageList.tsx b/packages/message-sdk/src/components/MessageList.tsx index 4d261e0b9..a8a9f7cea 100644 --- a/packages/message-sdk/src/components/MessageList.tsx +++ b/packages/message-sdk/src/components/MessageList.tsx @@ -42,6 +42,20 @@ export const MessageList = ({ }) => { const theme = useCustomTheme(); + const sortedChats = activeChats.sort( + (a, b) => + new Date( + (b.chatType === "collection" + ? b.chatProps.lastMessageTimestamp + : b.chatProps.last_message_timestamp) ?? 0 + ).getTime() - + new Date( + (a.chatType === "collection" + ? a.chatProps.lastMessageTimestamp + : a.chatProps.last_message_timestamp) ?? 0 + ).getTime() + ); + return ( ) : null} - {activeChats?.map((activeChat, index) => ( + {sortedChats?.map((activeChat, index) => (