diff --git a/native/chat/chat-thread-list-item.react.js b/native/chat/chat-thread-list-item.react.js index 73fed7795..c4a49c93c 100644 --- a/native/chat/chat-thread-list-item.react.js +++ b/native/chat/chat-thread-list-item.react.js @@ -1,168 +1,167 @@ // @flow import * as React from 'react'; import { Text, View } from 'react-native'; import type { ChatThreadItem } from 'lib/selectors/chat-selectors'; import type { ThreadInfo } from 'lib/types/thread-types'; import type { UserInfo } from 'lib/types/user-types'; import { shortAbsoluteDate } from 'lib/utils/date-utils'; import Button from '../components/button.react'; import ColorSplotch from '../components/color-splotch.react'; import { SingleLine } from '../components/single-line.react'; import { useColors, useStyles } from '../themes/colors'; import ChatThreadListSeeMoreSidebars from './chat-thread-list-see-more-sidebars.react'; import ChatThreadListSidebar from './chat-thread-list-sidebar.react'; import MessagePreview from './message-preview.react'; import SwipeableThread from './swipeable-thread.react'; type Props = {| +data: ChatThreadItem, +onPressItem: ( data: ThreadInfo, pendingPersonalThreadUserInfo?: UserInfo, ) => void, +onPressSeeMoreSidebars: (threadInfo: ThreadInfo) => void, +onSwipeableWillOpen: (threadInfo: ThreadInfo) => void, +currentlyOpenedSwipeableId: string, |}; function ChatThreadListItem({ data, onPressItem, onPressSeeMoreSidebars, onSwipeableWillOpen, currentlyOpenedSwipeableId, }: Props) { const styles = useStyles(unboundStyles); const colors = useColors(); const lastMessage = React.useMemo(() => { const mostRecentMessageInfo = data.mostRecentMessageInfo; if (!mostRecentMessageInfo) { return ( No messages ); } return ( ); }, [data.mostRecentMessageInfo, data.threadInfo, styles]); const sidebars = data.sidebars.map((sidebarItem) => { if (sidebarItem.type === 'sidebar') { const { type, ...sidebarInfo } = sidebarItem; return ( ); } else { return ( ); } }); const onPress = React.useCallback(() => { onPressItem(data.threadInfo, data.pendingPersonalThreadUserInfo); }, [onPressItem, data.threadInfo, data.pendingPersonalThreadUserInfo]); const lastActivity = shortAbsoluteDate(data.lastUpdatedTime); const unreadStyle = data.threadInfo.currentUser.unread ? styles.unread : null; return ( <> {sidebars} ); } const unboundStyles = { colorSplotch: { marginLeft: 10, marginTop: 2, }, container: { height: 60, paddingLeft: 10, paddingRight: 10, paddingTop: 5, backgroundColor: 'listBackground', }, lastActivity: { color: 'listForegroundTertiaryLabel', fontSize: 16, marginLeft: 10, }, noMessages: { color: 'listForegroundTertiaryLabel', flex: 1, fontSize: 16, fontStyle: 'italic', paddingLeft: 10, }, row: { flex: 1, flexDirection: 'row', justifyContent: 'space-between', }, threadName: { color: 'listForegroundSecondaryLabel', flex: 1, fontSize: 20, paddingLeft: 10, }, unread: { color: 'listForegroundLabel', fontWeight: 'bold', }, }; export default ChatThreadListItem;