diff options
Diffstat (limited to 'src/components/feeds')
-rw-r--r-- | src/components/feeds/PostFeedVideoGridRow.tsx | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/components/feeds/PostFeedVideoGridRow.tsx b/src/components/feeds/PostFeedVideoGridRow.tsx new file mode 100644 index 000000000..7f9898083 --- /dev/null +++ b/src/components/feeds/PostFeedVideoGridRow.tsx @@ -0,0 +1,67 @@ +import {View} from 'react-native' +import {AppBskyEmbedVideo} from '@atproto/api' + +import {logEvent} from '#/lib/statsig/statsig' +import {FeedPostSliceItem} from '#/state/queries/post-feed' +import {VideoFeedSourceContext} from '#/screens/VideoFeed/types' +import {atoms as a, useGutters} from '#/alf' +import * as Grid from '#/components/Grid' +import { + VideoPostCard, + VideoPostCardPlaceholder, +} from '#/components/VideoPostCard' + +export function PostFeedVideoGridRow({ + items: slices, + sourceContext, +}: { + items: FeedPostSliceItem[] + sourceContext: VideoFeedSourceContext +}) { + const gutters = useGutters(['base', 'base', 0, 'base']) + const posts = slices + .filter(slice => AppBskyEmbedVideo.isView(slice.post.embed)) + .map(slice => ({ + post: slice.post, + moderation: slice.moderation, + })) + + /** + * This should not happen because we should be filtering out posts without + * videos within the `PostFeed` component. + */ + if (posts.length !== slices.length) return null + + return ( + <View style={[gutters]}> + <View style={[a.flex_row, a.gap_sm]}> + <Grid.Row gap={a.gap_sm.gap}> + {posts.map(post => ( + <Grid.Col key={post.post.uri} width={1 / 2}> + <VideoPostCard + post={post.post} + sourceContext={sourceContext} + moderation={post.moderation} + onInteract={() => { + logEvent('videoCard:click', {context: 'feed'}) + }} + /> + </Grid.Col> + ))} + </Grid.Row> + </View> + </View> + ) +} + +export function PostFeedVideoGridRowPlaceholder() { + const gutters = useGutters(['base', 'base', 0, 'base']) + return ( + <View style={[gutters]}> + <View style={[a.flex_row, a.gap_sm]}> + <VideoPostCardPlaceholder /> + <VideoPostCardPlaceholder /> + </View> + </View> + ) +} |