Fix effect cleanup

This commit is contained in:
Dan Abramov
2025-01-19 23:08:56 +00:00
parent f28d139db0
commit d01d01812e
+6 -6
View File
@@ -479,19 +479,19 @@ let VideoItem = ({
const {sendInteraction} = useFeedFeedbackContext() const {sendInteraction} = useFeedFeedbackContext()
useEffect(() => { useEffect(() => {
let to: NodeJS.Timeout | null = null if (active) {
if (active && !to) { const to = setTimeout(() => {
to = setTimeout(() => {
sendInteraction({ sendInteraction({
item: post.uri, item: post.uri,
event: 'app.bsky.feed.defs#interactionSeen', event: 'app.bsky.feed.defs#interactionSeen',
feedContext, feedContext,
}) })
}, 1000) }, 1000)
} else if (!active && to) { return () => {
clearTimeout(to) clearTimeout(to)
}
} }
}, [active, post, feedContext, sendInteraction]) }, [active, post.uri, feedContext, sendInteraction])
return ( return (
<View style={[a.relative, {height, width}]}> <View style={[a.relative, {height, width}]}>