diff --git a/src/components/Threads/ThreadList/ThreadListItemUI.tsx b/src/components/Threads/ThreadList/ThreadListItemUI.tsx index 1cea2622f..386d02237 100644 --- a/src/components/Threads/ThreadList/ThreadListItemUI.tsx +++ b/src/components/Threads/ThreadList/ThreadListItemUI.tsx @@ -32,7 +32,6 @@ export const ThreadListItemUI = ({ (nextValue: ThreadState) => ({ channel: nextValue.channel, deletedAt: nextValue.deletedAt, - latestReply: nextValue.replies.at(-1), ownUnreadMessageCount: (client.userID && nextValue.read[client.userID]?.unreadMessageCount) || 0, parentMessage: nextValue.parentMessage, @@ -45,13 +44,22 @@ export const ThreadListItemUI = ({ const { channel, deletedAt, - latestReply, ownUnreadMessageCount, parentMessage, participants, replyCount, } = useStateStore(thread.state, selector); + // The latest-reply preview comes from the messagePaginator, the sole reply source. + const latestReplySelector = useMemo( + () => () => ({ + latestReply: thread.messagePaginator.state.getLatestValue().items?.at(-1), + }), + [thread.messagePaginator], + ); + const { latestReply } = + useStateStore(thread.messagePaginator.state, latestReplySelector) ?? {}; + const { displayTitle: channelDisplayTitle } = useChannelPreviewInfo({ channel }); const { t } = useTranslationContext('ThreadListItemUI'); const { open } = useChatViewNavigation();