MCPcopy Create free account
hub / github.com/CommE2E/comm / ThreadAvatar

Function ThreadAvatar

web/avatars/thread-avatar.react.js:31–76  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

29};
30
31function ThreadAvatar(props: Props): React.Node {
32 const { threadInfo, size, showSpinner } = props;
33
34 const avatarInfo = useAvatarForThread(threadInfo);
35
36 const viewerID = useSelector(
37 state => state.currentUserInfo && state.currentUserInfo.id,
38 );
39
40 const communityID = getCommunity(threadInfo);
41 const communityInfo: ?CommunityInfo = useSelector(state => {
42 if (!communityID) {
43 return null;
44 }
45 return state.communityStore.communityInfos[communityID];
46 });
47
48 let displayUserIDForThread;
49 if (threadTypeIsPrivate(threadInfo.type)) {
50 displayUserIDForThread = viewerID;
51 } else if (threadTypeIsPersonal(threadInfo.type)) {
52 displayUserIDForThread = getSingleOtherUser(threadInfo, viewerID);
53 }
54
55 const userInfos = useSelector(state => state.userStore.userInfos);
56 const auxUserInfos = useSelector(state => state.auxUserStore.auxUserInfos);
57
58 const displayUser = useDisplayUserForThread(
59 displayUserIDForThread,
60 userInfos,
61 auxUserInfos,
62 );
63
64 const resolvedThreadAvatar = useResolvedThreadAvatar(avatarInfo, {
65 userProfileInfo: displayUser,
66 channelInfo: { fcChannelID: communityInfo?.farcasterChannelID },
67 });
68
69 return (
70 <Avatar
71 size={size}
72 avatarInfo={resolvedThreadAvatar}
73 showSpinner={showSpinner}
74 />
75 );
76}
77
78export default ThreadAvatar;

Callers

nothing calls this directly

Calls 8

useAvatarForThreadFunction · 0.90
useSelectorFunction · 0.90
getCommunityFunction · 0.90
threadTypeIsPrivateFunction · 0.90
threadTypeIsPersonalFunction · 0.90
getSingleOtherUserFunction · 0.90
useDisplayUserForThreadFunction · 0.90
useResolvedThreadAvatarFunction · 0.90

Tested by

no test coverage detected