wire in feed context again...

This commit is contained in:
Hailey
2025-01-18 16:11:14 -08:00
parent d83a62795f
commit c8f276befc
+37 -4
View File
@@ -161,6 +161,12 @@ type CurrentSource = {
moderation?: ModerationDecision moderation?: ModerationDecision
} | null } | null
type VideoItem = {
moderation: ModerationDecision
post: AppBskyFeedDefs.PostView
feedContext: string | undefined
}
function Feed() { function Feed() {
const {params} = useRoute<RouteProp<CommonNavigatorParams, 'VideoFeed'>>() const {params} = useRoute<RouteProp<CommonNavigatorParams, 'VideoFeed'>>()
const isFocused = useIsFocused() const isFocused = useIsFocused()
@@ -186,7 +192,20 @@ function Feed() {
const videos = useMemo(() => { const videos = useMemo(() => {
let vids = let vids =
data?.pages data?.pages
.flatMap(page => page.slices.flatMap(slice => slice.items)) .map(page => {
const items = []
for (const slice of page.slices) {
for (const i of slice.items) {
items.push({
moderation: i.moderation,
post: i.post,
feedContext: slice.feedContext,
})
}
}
return items
})
.flatMap(items => items)
.filter(item => AppBskyEmbedVideo.isView(item.post.embed)) || [] .filter(item => AppBskyEmbedVideo.isView(item.post.embed)) || []
const startingVideoIndex = vids?.findIndex(video => { const startingVideoIndex = vids?.findIndex(video => {
return video.post.uri === params.initialPostUri return video.post.uri === params.initialPostUri
@@ -209,7 +228,7 @@ function Feed() {
const scrollGesture = useMemo(() => Gesture.Native(), []) const scrollGesture = useMemo(() => Gesture.Native(), [])
const renderItem: ListRenderItem<FeedPostSliceItem> = useCallback( const renderItem: ListRenderItem<VideoItem> = useCallback(
({item, index}) => { ({item, index}) => {
const {post} = item const {post} = item
@@ -233,6 +252,7 @@ function Feed() {
} }
moderation={currentSource?.moderation} moderation={currentSource?.moderation}
scrollGesture={scrollGesture} scrollGesture={scrollGesture}
feedContext={item.feedContext}
/> />
) )
}, },
@@ -438,6 +458,7 @@ function VideoItem({
active, active,
scrollGesture, scrollGesture,
moderation, moderation,
feedContext,
}: { }: {
player?: VideoPlayer player?: VideoPlayer
post: AppBskyFeedDefs.PostView post: AppBskyFeedDefs.PostView
@@ -445,6 +466,7 @@ function VideoItem({
active: boolean active: boolean
scrollGesture: NativeGesture scrollGesture: NativeGesture
moderation?: ModerationDecision moderation?: ModerationDecision
feedContext: string | undefined
}) { }) {
const postShadow = usePostShadow(post) const postShadow = usePostShadow(post)
const {width, height} = useSafeAreaFrame() const {width, height} = useSafeAreaFrame()
@@ -457,12 +479,13 @@ function VideoItem({
sendInteraction({ sendInteraction({
item: post.uri, item: post.uri,
event: 'app.bsky.feed.defs#interactionSeen', event: 'app.bsky.feed.defs#interactionSeen',
feedContext,
}) })
}, 1000) }, 1000)
} else if (!active && to) { } else if (!active && to) {
clearTimeout(to) clearTimeout(to)
} }
}, [active, post, sendInteraction]) }, [active, post, feedContext, sendInteraction])
return ( return (
<View style={[a.relative, {height, width}]}> <View style={[a.relative, {height, width}]}>
@@ -502,6 +525,7 @@ function VideoItem({
active={active} active={active}
scrollGesture={scrollGesture} scrollGesture={scrollGesture}
moderation={moderation} moderation={moderation}
feedContext={feedContext}
/> />
)} )}
</> </>
@@ -641,6 +665,7 @@ function Overlay({
active, active,
scrollGesture, scrollGesture,
moderation, moderation,
feedContext,
}: { }: {
player?: VideoPlayer player?: VideoPlayer
post: Shadow<AppBskyFeedDefs.PostView> post: Shadow<AppBskyFeedDefs.PostView>
@@ -648,6 +673,7 @@ function Overlay({
active: boolean active: boolean
scrollGesture: NativeGesture scrollGesture: NativeGesture
moderation: ModerationDecision moderation: ModerationDecision
feedContext: string | undefined
}) { }) {
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
@@ -683,7 +709,11 @@ function Overlay({
<Hider.Content> <Hider.Content>
<View style={[a.absolute, a.inset_0, a.z_20]}> <View style={[a.absolute, a.inset_0, a.z_20]}>
<View style={[a.flex_1]}> <View style={[a.flex_1]}>
<PlayPauseTapArea player={player} post={post} /> <PlayPauseTapArea
player={player}
post={post}
feedContext={feedContext}
/>
</View> </View>
<LinearGradient <LinearGradient
@@ -898,9 +928,11 @@ function VideoItemPlaceholder({
function PlayPauseTapArea({ function PlayPauseTapArea({
player, player,
post, post,
feedContext,
}: { }: {
player?: VideoPlayer player?: VideoPlayer
post: Shadow<AppBskyFeedDefs.PostView> post: Shadow<AppBskyFeedDefs.PostView>
feedContext: string | undefined
}) { }) {
const doubleTapRef = useRef<ReturnType<typeof setTimeout> | null>(null) const doubleTapRef = useRef<ReturnType<typeof setTimeout> | null>(null)
const playHaptic = useHaptics() const playHaptic = useHaptics()
@@ -927,6 +959,7 @@ function PlayPauseTapArea({
sendInteraction({ sendInteraction({
item: post.uri, item: post.uri,
event: 'app.bsky.feed.defs#interactionLike', event: 'app.bsky.feed.defs#interactionLike',
feedContext,
}) })
} else { } else {
doubleTapRef.current = setTimeout(togglePlayPause, 200) doubleTapRef.current = setTimeout(togglePlayPause, 200)