Filter out posts without videos
This commit is contained in:
@@ -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>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user