Filter only videos
This commit is contained in:
@@ -140,15 +140,16 @@ export function VideoFeed({}: NativeStackScreenProps<
|
|||||||
]}>
|
]}>
|
||||||
<Header sourceContext={params} />
|
<Header sourceContext={params} />
|
||||||
</View>
|
</View>
|
||||||
<Inner />
|
<Feed />
|
||||||
</Layout.Screen>
|
</Layout.Screen>
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Inner() {
|
function Feed() {
|
||||||
const {params} = useRoute<RouteProp<CommonNavigatorParams, 'VideoFeed'>>()
|
const {params} = useRoute<RouteProp<CommonNavigatorParams, 'VideoFeed'>>()
|
||||||
const isFocused = useIsFocused()
|
const isFocused = useIsFocused()
|
||||||
|
const {hasSession} = useSession()
|
||||||
const feedDesc = useMemo(() => {
|
const feedDesc = useMemo(() => {
|
||||||
switch (params.type) {
|
switch (params.type) {
|
||||||
case 'feedgen':
|
case 'feedgen':
|
||||||
@@ -161,7 +162,7 @@ function Inner() {
|
|||||||
throw new Error(`Invalid video feed params ${JSON.stringify(params)}`)
|
throw new Error(`Invalid video feed params ${JSON.stringify(params)}`)
|
||||||
}
|
}
|
||||||
}, [params])
|
}, [params])
|
||||||
|
const feedFeedback = useFeedFeedback(feedDesc, hasSession)
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
isFetching,
|
isFetching,
|
||||||
@@ -170,18 +171,19 @@ function Inner() {
|
|||||||
isFetchingNextPage,
|
isFetchingNextPage,
|
||||||
fetchNextPage,
|
fetchNextPage,
|
||||||
} = usePostFeedQuery(feedDesc)
|
} = usePostFeedQuery(feedDesc)
|
||||||
const {hasSession} = useSession()
|
const videos = React.useMemo(() => {
|
||||||
const feedFeedback = useFeedFeedback(feedDesc, hasSession)
|
let vids =
|
||||||
|
data?.pages
|
||||||
let videos = data?.pages.flatMap(page =>
|
.flatMap(page => page.slices.flatMap(slice => slice.items))
|
||||||
page.slices.flatMap(slice => slice.items),
|
.filter(item => AppBskyEmbedVideo.isView(item.post.embed)) || []
|
||||||
)
|
const startingVideoIndex = vids?.findIndex(video => {
|
||||||
const startingVideoIndex = videos?.findIndex(video => {
|
return video.post.uri === params.initialPostUri
|
||||||
return video.post.uri === params.initialPostUri
|
})
|
||||||
})
|
if (vids && startingVideoIndex && startingVideoIndex > -1) {
|
||||||
if (videos && startingVideoIndex && startingVideoIndex > -1) {
|
vids = vids.slice(startingVideoIndex)
|
||||||
videos = videos.slice(startingVideoIndex)
|
}
|
||||||
}
|
return vids
|
||||||
|
}, [data, params.initialPostUri])
|
||||||
|
|
||||||
const [currentSources, setCurrentSources] = useState<
|
const [currentSources, setCurrentSources] = useState<
|
||||||
[string | null, string | null, string | null]
|
[string | null, string | null, string | null]
|
||||||
|
|||||||
Reference in New Issue
Block a user