diff --git a/native/avatars/thread-avatar.react.js b/native/avatars/thread-avatar.react.js --- a/native/avatars/thread-avatar.react.js +++ b/native/avatars/thread-avatar.react.js @@ -23,10 +23,11 @@ type Props = { +threadInfo: RawThreadInfo | ThreadInfo | ResolvedThreadInfo, +size: AvatarSize, + +farcasterChannelID?: string, }; function ThreadAvatar(props: Props): React.Node { - const { threadInfo, size } = props; + const { threadInfo, size, farcasterChannelID } = props; const avatarInfo = useAvatarForThread(threadInfo); @@ -66,7 +67,9 @@ const resolvedThreadAvatar = useResolvedThreadAvatar(avatarInfo, { userProfileInfo: displayUser, - channelInfo: { fcChannelID: communityInfo?.farcasterChannelID }, + channelInfo: { + fcChannelID: farcasterChannelID ?? communityInfo?.farcasterChannelID, + }, }); return ; diff --git a/native/components/community-joiner-modal.react.js b/native/components/community-joiner-modal.react.js --- a/native/components/community-joiner-modal.react.js +++ b/native/components/community-joiner-modal.react.js @@ -62,55 +62,64 @@ [communities], ); - const generateThreadInfos = React.useCallback( + const generateThreadInfosAndFCChannelIDs = React.useCallback( (communityList: $ReadOnlyArray) => communityList - .map(community => - community.threadInfo - ? threadInfoFromRawThreadInfo( - community.threadInfo, - viewerID, - userInfos, - ) - : null, - ) + .map(community => { + const { farcasterChannelID, threadInfo } = community; + if (!farcasterChannelID || !threadInfo) { + return null; + } + return { + threadInfo: threadInfoFromRawThreadInfo( + threadInfo, + viewerID, + userInfos, + ), + farcasterChannelID, + }; + }) .filter(Boolean), [userInfos, viewerID], ); - const generalThreadInfos = React.useMemo( - () => generateThreadInfos(generalCommunities), - [generateThreadInfos, generalCommunities], + const generalThreadInfosAndFCChannelIDs = React.useMemo( + () => generateThreadInfosAndFCChannelIDs(generalCommunities), + [generateThreadInfosAndFCChannelIDs, generalCommunities], ); - const cryptoThreadInfos = React.useMemo( - () => generateThreadInfos(cryptoCommunities), - [generateThreadInfos, cryptoCommunities], + const cryptoThreadInfosAndFCChannelIDs = React.useMemo( + () => generateThreadInfosAndFCChannelIDs(cryptoCommunities), + [generateThreadInfosAndFCChannelIDs, cryptoCommunities], ); - const generalIndex = useThreadSearchIndex(generalThreadInfos); - const cryptoIndex = useThreadSearchIndex(cryptoThreadInfos); + const generalIndex = useThreadSearchIndex( + generalThreadInfosAndFCChannelIDs.map(item => item.threadInfo), + ); + const cryptoIndex = useThreadSearchIndex( + cryptoThreadInfosAndFCChannelIDs.map(item => item.threadInfo), + ); const renderGeneralTab = React.useCallback( () => ( ), - [generalIndex, generalThreadInfos, styles.threadListItem], + [generalIndex, generalThreadInfosAndFCChannelIDs, styles.threadListItem], ); const renderCryptoTab = React.useCallback( () => ( ), - [cryptoIndex, cryptoThreadInfos, styles.threadListItem], + [cryptoIndex, cryptoThreadInfosAndFCChannelIDs, styles.threadListItem], ); const [index, setIndex] = React.useState(0); diff --git a/native/components/community-list-item.react.js b/native/components/community-list-item.react.js --- a/native/components/community-list-item.react.js +++ b/native/components/community-list-item.react.js @@ -36,10 +36,11 @@ type Props = { +threadInfo: ThreadInfo, +style: ViewStyle, + +farcasterChannelID?: string, }; function CommunityListItem(props: Props): React.Node { - const { threadInfo: initialThreadInfo, style } = props; + const { threadInfo: initialThreadInfo, style, farcasterChannelID } = props; // `initialThreadInfo` will not update if the user leaves or joins the thread, // so we also need `reduxThreadInfo` to track thread membership and @@ -183,7 +184,11 @@ return ( - + {resolvedThreadInfo.uiName} diff --git a/native/components/community-list.react.js b/native/components/community-list.react.js --- a/native/components/community-list.react.js +++ b/native/components/community-list.react.js @@ -13,6 +13,11 @@ import { useIndicatorStyle, useStyles } from '../themes/colors.js'; import type { ViewStyle } from '../types/styles.js'; +export type ThreadInfoAndFarcasterChannelID = { + +threadInfo: ThreadInfo, + +farcasterChannelID: string, +}; + const unboundStyles = { search: { marginBottom: 8, @@ -20,22 +25,24 @@ }; type Props = { - +threadInfos: $ReadOnlyArray, + +threadInfosAndFCChannelIDs: $ReadOnlyArray, +itemStyle: ViewStyle, +searchIndex: SearchIndex, }; -const keyExtractor = (threadInfo: ThreadInfo): string => threadInfo.id; +const keyExtractor = ( + threadInfoAndFarcasterChannelID: ThreadInfoAndFarcasterChannelID, +): string => threadInfoAndFarcasterChannelID.threadInfo.id; const getItemLayout = ( - data: ?$ReadOnlyArray, + data: ?$ReadOnlyArray, index: number, ): { length: number, offset: number, index: number } => { return { length: 24, offset: 24 * index, index }; }; function CommunityList(props: Props): React.Node { - const { threadInfos, itemStyle, searchIndex } = props; + const { threadInfosAndFCChannelIDs, itemStyle, searchIndex } = props; const styles = useStyles(unboundStyles); const indicatorStyle = useIndicatorStyle(); @@ -45,14 +52,17 @@ >([]); const listData = React.useMemo( - () => (searchText ? searchResults : threadInfos), - [searchText, searchResults, threadInfos], + () => (searchText ? searchResults : threadInfosAndFCChannelIDs), + [searchText, searchResults, threadInfosAndFCChannelIDs], ); const onChangeSearchText = React.useCallback( (text: string) => { invariant(searchIndex, 'searchIndex should be set'); const results = searchIndex.getSearchResults(text); + const threadInfos = threadInfosAndFCChannelIDs.map( + item => item.threadInfo, + ); const threadInfoResults = reorderThreadSearchResults( threadInfos, results, @@ -60,12 +70,16 @@ setSearchText(text); setSearchResults(threadInfoResults); }, - [searchIndex, threadInfos], + [searchIndex, threadInfosAndFCChannelIDs], ); const renderItem = React.useCallback( - ({ item }: { +item: ThreadInfo, ... }): React.Node => ( - + ({ item }: { +item: ThreadInfoAndFarcasterChannelID, ... }): React.Node => ( + ), [itemStyle], );