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 @@ -23,15 +23,28 @@ +item: ChatThreadItem, +setModal: (modal: ?React.Node) => void, }; + +function useLastActiveTime(item: ChatThreadItem): string { + const timeZone = useSelector(state => state.timeZone); + const lastUpdatedTimes = item.sidebars.map(sidebar => { + if (sidebar.type === 'sidebar') { + return sidebar.lastUpdatedTime; + } else { + return 0; + } + }); + + const recentLastTime = Math.max(item.lastUpdatedTime, ...lastUpdatedTimes); + return shortAbsoluteDate(recentLastTime, timeZone); +} + 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 lastActivity = useLastActiveTime(item); const active = useThreadIsActive(threadID); const containerClassName = React.useMemo( diff --git a/web/chat/sidebar-item.react.js b/web/chat/sidebar-item.react.js --- a/web/chat/sidebar-item.react.js +++ b/web/chat/sidebar-item.react.js @@ -4,9 +4,7 @@ import * as React from 'react'; import type { SidebarInfo } from 'lib/types/thread-types'; -import { shortAbsoluteDate } from 'lib/utils/date-utils'; -import { useSelector } from '../redux/redux-utils'; import { useOnClickThread } from '../selectors/nav-selectors'; import SWMansionIcon from '../SWMansionIcon.react'; import css from './chat-thread-list.css'; @@ -15,16 +13,12 @@ +sidebarInfo: SidebarInfo, }; function SidebarItem(props: Props): React.Node { - const { threadInfo, lastUpdatedTime } = props.sidebarInfo; + const { threadInfo } = props.sidebarInfo; const threadID = threadInfo.id; - const onClick = useOnClickThread(threadID); - - const timeZone = useSelector(state => state.timeZone); - const lastActivity = shortAbsoluteDate(lastUpdatedTime, timeZone); - const { unread } = threadInfo.currentUser; const unreadCls = classNames(css.sidebarTitle, { [css.unread]: unread }); + return ( <> @@ -32,14 +26,6 @@
{threadInfo.uiName}
-
- {lastActivity} -