diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js --- a/lib/shared/thread-utils.js +++ b/lib/shared/thread-utils.js @@ -1177,6 +1177,17 @@ return null; } +function useLastActiveTime(item: ChatThreadItem): number { + const lastUpdatedTimes = item.sidebars.map(sidebar => { + if (sidebar.type === 'sidebar') { + return sidebar.lastUpdatedTime; + } else { + return 0; + } + }); + return Math.max(item.lastUpdatedTime, ...lastUpdatedTimes); +} + export { colorIsDark, generateRandomColor, @@ -1231,4 +1242,5 @@ threadTypeCanBePending, getContainingThreadID, getCommunity, + useLastActiveTime, }; diff --git a/web/chat/chat-thread-list-item.react.js b/web/chat/chat-thread-list-item.react.js --- a/web/chat/chat-thread-list-item.react.js +++ b/web/chat/chat-thread-list-item.react.js @@ -5,6 +5,7 @@ import type { ChatThreadItem } from 'lib/selectors/chat-selectors'; import { useAncestorThreads } from 'lib/shared/ancestor-threads'; +import { useLastActiveTime } from 'lib/shared/thread-utils'; import { shortAbsoluteDate } from 'lib/utils/date-utils'; import { useSelector } from '../redux/redux-utils'; @@ -23,15 +24,16 @@ +item: ChatThreadItem, +setModal: (modal: ?React.Node) => void, }; + function ChatThreadListItem(props: Props): React.Node { const { item, setModal } = props; const { threadInfo } = item; const threadID = item.threadInfo.id; const ancestorThreads = useAncestorThreads(threadInfo); const onClick = useOnClickThread(threadID); - const timeZone = useSelector(state => state.timeZone); - const lastActivity = shortAbsoluteDate(item.lastUpdatedTime, timeZone); + const rawLastActivity = useLastActiveTime(item); + const lastActivity = shortAbsoluteDate(rawLastActivity, timeZone); const active = useThreadIsActive(threadID); const containerClassName = React.useMemo(