diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js --- a/lib/selectors/chat-selectors.js +++ b/lib/selectors/chat-selectors.js @@ -92,32 +92,23 @@ ); } -function getMostRecentMessageInfo( +function getLastUpdatedTime( threadInfo: ThreadInfo, messageStore: MessageStore, messages: { +[id: string]: ?MessageInfo }, -): ?MessageInfo { +): number { const thread = messageStore.threads[threadInfo.id]; if (!thread) { - return null; + return threadInfo.creationTime; } for (const messageID of thread.messageIDs) { const messageInfo = messages[messageID]; if (!messageInfo || isEmptyMediaMessage(messageInfo)) { continue; } - return messageInfo; + return messageInfo.time; } - return null; -} - -function getLastUpdatedTime( - threadInfo: ThreadInfo, - mostRecentMessageInfo: ?MessageInfo, -): number { - return mostRecentMessageInfo - ? mostRecentMessageInfo.time - : threadInfo.creationTime; + return threadInfo.creationTime; } function useCreateChatThreadItem(): ThreadInfo => ChatThreadItem { @@ -126,18 +117,14 @@ const messageStore = useSelector(state => state.messageStore); return React.useCallback( threadInfo => { - const mostRecentMessageInfo = getMostRecentMessageInfo( - threadInfo, - messageStore, - messageInfos, - ); const mostRecentNonLocalMessage = getMostRecentNonLocalMessageID( threadInfo.id, messageStore, ); const lastUpdatedTime = getLastUpdatedTime( threadInfo, - mostRecentMessageInfo, + messageStore, + messageInfos, ); const sidebars = sidebarInfos[threadInfo.id] ?? [];