diff --git a/native/chat/settings/thread-settings-media-gallery.react.js b/native/chat/settings/thread-settings-media-gallery.react.js --- a/native/chat/settings/thread-settings-media-gallery.react.js +++ b/native/chat/settings/thread-settings-media-gallery.react.js @@ -9,6 +9,10 @@ import { useFetchThreadMedia } from 'lib/actions/thread-actions.js'; import type { MediaInfo, Media } from 'lib/types/media-types'; +import { + ThreadSettingsCategoryActionHeader, + ThreadSettingsCategoryFooter, +} from './thread-settings-category.react.js'; import GestureTouchableOpacity from '../../components/gesture-touchable-opacity.react.js'; import Multimedia from '../../media/multimedia.react.js'; import { @@ -30,6 +34,7 @@ +verticalBounds: ?VerticalBounds, +offset?: number, +activeTab?: string, + +onPressSeeMore?: () => mixed, }; function ThreadSettingsMediaGallery( @@ -47,7 +52,8 @@ // E.g. 16px, media, galleryItemGap, media, galleryItemGap, media, 16px const galleryItemWidth = (width - 32 - (numColumns - 1) * galleryItemGap) / numColumns; - const { threadID, limit, verticalBounds, offset, activeTab } = props; + const { threadID, limit, verticalBounds, offset, activeTab, onPressSeeMore } = + props; const [mediaInfos, setMediaInfos] = React.useState<$ReadOnlyArray>([]); const callFetchThreadMedia = useFetchThreadMedia(); @@ -125,17 +131,64 @@ setMediaInfos([...mediaInfos, ...result.media]); }, [callFetchThreadMedia, mediaInfos, threadID, limit]); - return ( - - { + if (mediaInfos.length === 0 || !onPressSeeMore) { + return { + header: null, + footer: null, + }; + } + + const threadSettingsHeader = ( + - - ); + ); + + const threadSettingsFooter = ( + + ); + + return { + header: threadSettingsHeader, + footer: threadSettingsFooter, + }; + }, [mediaInfos.length, onPressSeeMore]); + + const threadSettingsMediaGallery = React.useMemo(() => { + if (mediaInfos.length === 0) { + return null; + } + + return ( + <> + {header} + + + + {footer} + + ); + }, [ + filteredMediaInfos, + footer, + header, + mediaInfos.length, + offset, + onEndReached, + renderItem, + styles.flatListContainer, + ]); + + return threadSettingsMediaGallery; } type MediaGalleryItemProps = { diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js --- a/native/chat/settings/thread-settings.react.js +++ b/native/chat/settings/thread-settings.react.js @@ -699,14 +699,6 @@ const listData: ChatSettingsItem[] = []; const limit = 6; - listData.push({ - itemType: 'actionHeader', - key: 'mediaGalleryHeader', - title: 'Media Gallery', - actionText: 'See more', - onPress: this.onPressSeeMoreMediaGallery, - }); - listData.push({ itemType: 'mediaGallery', key: 'mediaGallery', @@ -715,12 +707,6 @@ verticalBounds, }); - listData.push({ - itemType: 'footer', - key: 'mediaGalleryFooter', - categoryType: 'outline', - }); - return listData; }, ); @@ -1025,6 +1011,7 @@ threadID={item.threadInfo.id} limit={item.limit} verticalBounds={item.verticalBounds} + onPressSeeMore={this.onPressSeeMoreMediaGallery} /> ); } else if (item.itemType === 'leaveThread') {