diff --git a/native/chat/chat-thread-list-item.react.js b/native/chat/chat-thread-list-item.react.js
index fe303be3b..cd7cafef1 100644
--- a/native/chat/chat-thread-list-item.react.js
+++ b/native/chat/chat-thread-list-item.react.js
@@ -1,221 +1,232 @@
// @flow
import * as React from 'react';
import { Text, View } from 'react-native';
import type { ChatThreadItem } from 'lib/selectors/chat-selectors.js';
+import { useGetAvatarForThread } from 'lib/shared/avatar-utils.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';
import type { UserInfo } from 'lib/types/user-types.js';
import { shortAbsoluteDate } from 'lib/utils/date-utils.js';
import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js';
import ChatThreadListSeeMoreSidebars from './chat-thread-list-see-more-sidebars.react.js';
import ChatThreadListSidebar from './chat-thread-list-sidebar.react.js';
import MessagePreview from './message-preview.react.js';
import SwipeableThread from './swipeable-thread.react.js';
+import Avatar from '../components/avatar.react.js';
import Button from '../components/button.react.js';
import ColorSplotch from '../components/color-splotch.react.js';
import { SingleLine } from '../components/single-line.react.js';
import ThreadAncestorsLabel from '../components/thread-ancestors-label.react.js';
import UnreadDot from '../components/unread-dot.react.js';
import { useColors, useStyles } from '../themes/colors.js';
+import { useShouldRenderAvatars } from '../utils/avatar-utils.js';
type Props = {
+data: ChatThreadItem,
+onPressItem: (
threadInfo: ThreadInfo,
pendingPersonalThreadUserInfo?: UserInfo,
) => void,
+onPressSeeMoreSidebars: (threadInfo: ThreadInfo) => void,
+onSwipeableWillOpen: (threadInfo: ThreadInfo) => void,
+currentlyOpenedSwipeableId: string,
};
function ChatThreadListItem({
data,
onPressItem,
onPressSeeMoreSidebars,
onSwipeableWillOpen,
currentlyOpenedSwipeableId,
}: Props): React.Node {
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 numOfSidebarsWithExtendedArrow =
data.sidebars.filter(sidebarItem => sidebarItem.type === 'sidebar').length -
1;
const sidebars = data.sidebars.map((sidebarItem, index) => {
if (sidebarItem.type === 'sidebar') {
const { type, ...sidebarInfo } = sidebarItem;
return (
);
} else if (sidebarItem.type === 'seeMore') {
return (
);
} else {
return ;
}
});
const onPress = React.useCallback(() => {
onPressItem(data.threadInfo, data.pendingPersonalThreadUserInfo);
}, [onPressItem, data.threadInfo, data.pendingPersonalThreadUserInfo]);
const threadNameStyle = React.useMemo(() => {
if (!data.threadInfo.currentUser.unread) {
return styles.threadName;
}
return [styles.threadName, styles.unreadThreadName];
}, [
data.threadInfo.currentUser.unread,
styles.threadName,
styles.unreadThreadName,
]);
const lastActivity = shortAbsoluteDate(data.lastUpdatedTime);
const lastActivityStyle = React.useMemo(() => {
if (!data.threadInfo.currentUser.unread) {
return styles.lastActivity;
}
return [styles.lastActivity, styles.unreadLastActivity];
}, [
data.threadInfo.currentUser.unread,
styles.lastActivity,
styles.unreadLastActivity,
]);
const resolvedThreadInfo = useResolvedThreadInfo(data.threadInfo);
+ const avatarInfo = useGetAvatarForThread(data.threadInfo);
+ const shouldRenderAvatars = useShouldRenderAvatars();
+
+ const avatar = React.useMemo(() => {
+ if (!shouldRenderAvatars) {
+ return ;
+ }
+
+ return ;
+ }, [avatarInfo, data.threadInfo.color, shouldRenderAvatars]);
return (
<>
{sidebars}
>
);
}
const chatThreadListItemHeight = 70;
const spacerHeight = 6;
const unboundStyles = {
container: {
height: chatThreadListItemHeight,
justifyContent: 'center',
backgroundColor: 'listBackground',
},
content: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
colorSplotch: {
marginLeft: 6,
marginBottom: 12,
},
threadDetails: {
paddingLeft: 12,
paddingRight: 18,
justifyContent: 'center',
flex: 1,
marginTop: 5,
},
lastActivity: {
color: 'listForegroundTertiaryLabel',
fontSize: 14,
marginLeft: 10,
},
unreadLastActivity: {
color: 'listForegroundLabel',
fontWeight: 'bold',
},
noMessages: {
color: 'listForegroundTertiaryLabel',
flex: 1,
fontSize: 14,
fontStyle: 'italic',
},
row: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
threadName: {
color: 'listForegroundSecondaryLabel',
flex: 1,
fontSize: 21,
},
unreadThreadName: {
color: 'listForegroundLabel',
fontWeight: '500',
},
spacer: {
height: spacerHeight,
},
};
export { ChatThreadListItem, chatThreadListItemHeight, spacerHeight };
diff --git a/native/components/thread-list-thread.react.js b/native/components/thread-list-thread.react.js
index efdfae586..1dcf6ee07 100644
--- a/native/components/thread-list-thread.react.js
+++ b/native/components/thread-list-thread.react.js
@@ -1,85 +1,103 @@
// @flow
import * as React from 'react';
+import { useGetAvatarForThread } from 'lib/shared/avatar-utils.js';
+import type { ClientAvatar } from 'lib/types/avatar-types.js';
import type { ThreadInfo, ResolvedThreadInfo } from 'lib/types/thread-types.js';
import { useResolvedThreadInfo } from 'lib/utils/entity-helpers.js';
+import Avatar from './avatar.react.js';
import Button from './button.react.js';
import ColorSplotch from './color-splotch.react.js';
import { SingleLine } from './single-line.react.js';
import { type Colors, useStyles, useColors } from '../themes/colors.js';
import type { ViewStyle, TextStyle } from '../types/styles.js';
+import { useShouldRenderAvatars } from '../utils/avatar-utils.js';
type SharedProps = {
+onSelect: (threadID: string) => void,
+style?: ViewStyle,
+textStyle?: TextStyle,
};
type BaseProps = {
...SharedProps,
+threadInfo: ThreadInfo,
};
type Props = {
...SharedProps,
+threadInfo: ResolvedThreadInfo,
+ +avatarInfo: ClientAvatar,
+ +shouldRenderAvatars: boolean,
+colors: Colors,
+styles: typeof unboundStyles,
};
class ThreadListThread extends React.PureComponent {
render() {
const { modalIosHighlightUnderlay: underlayColor } = this.props.colors;
+
+ let avatar;
+ if (this.props.shouldRenderAvatars) {
+ avatar = ;
+ } else {
+ avatar = ;
+ }
+
return (
);
}
onSelect = () => {
this.props.onSelect(this.props.threadInfo.id);
};
}
const unboundStyles = {
button: {
alignItems: 'center',
flexDirection: 'row',
paddingLeft: 13,
},
text: {
color: 'modalForegroundLabel',
fontSize: 16,
paddingLeft: 9,
paddingRight: 12,
paddingVertical: 6,
},
};
const ConnectedThreadListThread: React.ComponentType =
React.memo(function ConnectedThreadListThread(props: BaseProps) {
const { threadInfo, ...rest } = props;
const styles = useStyles(unboundStyles);
const colors = useColors();
const resolvedThreadInfo = useResolvedThreadInfo(threadInfo);
+ const avatarInfo = useGetAvatarForThread(threadInfo);
+ const shouldRenderAvatars = useShouldRenderAvatars();
return (
);
});
export default ConnectedThreadListThread;