diff --git a/web/chat/chat-thread-list-item.react.js b/web/chat/chat-thread-list-item.react.js index 3f891de7c..ffc024cc3 100644 --- a/web/chat/chat-thread-list-item.react.js +++ b/web/chat/chat-thread-list-item.react.js @@ -1,63 +1,85 @@ // @flow import type { ChatThreadItem } from 'lib/selectors/chat-selectors'; import * as React from 'react'; import classNames from 'classnames'; import { shortAbsoluteDate } from 'lib/utils/date-utils'; import css from './chat-thread-list.css'; import MessagePreview from './message-preview.react'; import ChatThreadListItemMenu from './chat-thread-list-item-menu.react'; import { useSelector } from '../redux/redux-utils'; import { useOnClickThread, useThreadIsActive, } from '../selectors/nav-selectors'; type Props = {| +item: ChatThreadItem, |}; function ChatThreadListItem(props: Props) { const { item } = props; const threadID = item.threadInfo.id; const onClick = useOnClickThread(threadID); const timeZone = useSelector((state) => state.timeZone); const lastActivity = shortAbsoluteDate(item.lastUpdatedTime, timeZone); const active = useThreadIsActive(threadID); - const activeStyle = active ? css.activeThread : null; + const containerClassName = React.useMemo( + () => + classNames({ + [css.thread]: true, + [css.activeThread]: active, + }), + [active], + ); - const colorSplotchStyle = { backgroundColor: `#${item.threadInfo.color}` }; - const unread = item.threadInfo.currentUser.unread; + const { unread } = item.threadInfo.currentUser; + const titleClassName = React.useMemo( + () => + classNames({ + [css.title]: true, + [css.unread]: unread, + }), + [unread], + ); + const lastActivityClassName = React.useMemo( + () => + classNames({ + [css.lastActivity]: true, + [css.unread]: unread, + [css.dark]: !unread, + }), + [unread], + ); + + const { color } = item.threadInfo; + const colorSplotchStyle = React.useMemo( + () => ({ backgroundColor: `#${color}` }), + [color], + ); return ( -