Filter out posts without videos

This commit is contained in:
Eric Bailey
2025-01-16 13:44:43 -06:00
parent cfbb50c11a
commit a063966fb0
3 changed files with 35 additions and 23 deletions
+13 -2
View File
@@ -1,16 +1,27 @@
import {View} from 'react-native'
import {AppBskyEmbedVideo} from '@atproto/api'
import {FeedPostSliceItem} from '#/state/queries/post-feed'
import {atoms as a, useGutters} from '#/alf'
import {VideoPostCard} from '#/components/VideoPostCard'
export function PostFeedVideoGridRow({posts}: {posts: FeedPostSliceItem[]}) {
export function PostFeedVideoGridRow({slices}: {slices: FeedPostSliceItem[]}) {
const gutters = useGutters(['base', 'base', 0, 'base'])
const posts = slices
.filter(slice => AppBskyEmbedVideo.isView(slice.post.embed))
.map(slice => slice.post)
/**
* 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_lg]}>
{posts.map(post => (
<View key={post._reactKey} style={[a.flex_1]}>
<View key={post.uri} style={[a.flex_1]}>
<VideoPostCard post={post} />
</View>
))}