From 81d759f83f077dbbe03d78472285223ce112f75f Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Sat, 18 Jan 2025 11:05:12 -0600 Subject: [PATCH] Filter only videos --- src/screens/VideoFeed/index.tsx | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/screens/VideoFeed/index.tsx b/src/screens/VideoFeed/index.tsx index 5fdc7a0aae..ac93d72595 100644 --- a/src/screens/VideoFeed/index.tsx +++ b/src/screens/VideoFeed/index.tsx @@ -140,15 +140,16 @@ export function VideoFeed({}: NativeStackScreenProps< ]}>
- + ) } -function Inner() { +function Feed() { const {params} = useRoute>() const isFocused = useIsFocused() + const {hasSession} = useSession() const feedDesc = useMemo(() => { switch (params.type) { case 'feedgen': @@ -161,7 +162,7 @@ function Inner() { throw new Error(`Invalid video feed params ${JSON.stringify(params)}`) } }, [params]) - + const feedFeedback = useFeedFeedback(feedDesc, hasSession) const { data, isFetching, @@ -170,18 +171,19 @@ function Inner() { isFetchingNextPage, fetchNextPage, } = usePostFeedQuery(feedDesc) - const {hasSession} = useSession() - const feedFeedback = useFeedFeedback(feedDesc, hasSession) - - let videos = data?.pages.flatMap(page => - page.slices.flatMap(slice => slice.items), - ) - const startingVideoIndex = videos?.findIndex(video => { - return video.post.uri === params.initialPostUri - }) - if (videos && startingVideoIndex && startingVideoIndex > -1) { - videos = videos.slice(startingVideoIndex) - } + const videos = React.useMemo(() => { + let vids = + data?.pages + .flatMap(page => page.slices.flatMap(slice => slice.items)) + .filter(item => AppBskyEmbedVideo.isView(item.post.embed)) || [] + const startingVideoIndex = vids?.findIndex(video => { + return video.post.uri === params.initialPostUri + }) + if (vids && startingVideoIndex && startingVideoIndex > -1) { + vids = vids.slice(startingVideoIndex) + } + return vids + }, [data, params.initialPostUri]) const [currentSources, setCurrentSources] = useState< [string | null, string | null, string | null]