diff --git a/src/components/Post/Embed/VideoEmbed/index.tsx b/src/components/Post/Embed/VideoEmbed/index.tsx index f2c36e6a43..66ec01da9f 100644 --- a/src/components/Post/Embed/VideoEmbed/index.tsx +++ b/src/components/Post/Embed/VideoEmbed/index.tsx @@ -26,7 +26,7 @@ interface Props { post?: app.bsky.feed.defs.PostView } -export function VideoEmbed({embed}: Props) { +export function VideoEmbed({embed, post}: Props) { const [key, setKey] = useState(0) const renderError = useCallback( @@ -53,7 +53,7 @@ export function VideoEmbed({embed}: Props) { const contents = ( - + ) diff --git a/src/components/Post/Embed/VideoEmbed/index.web.tsx b/src/components/Post/Embed/VideoEmbed/index.web.tsx index c4aed50c2d..0c3f217791 100644 --- a/src/components/Post/Embed/VideoEmbed/index.web.tsx +++ b/src/components/Post/Embed/VideoEmbed/index.web.tsx @@ -53,6 +53,7 @@ export function VideoEmbed({ currentActiveView, } = useActiveVideoWeb() const [onScreen, setOnScreen] = useState(false) + const [meaningfullyVisible, setMeaningfullyVisible] = useState(false) const [isFullscreen] = useFullscreen() const lastKnownTime = useRef(undefined) const impressionTrackedRef = useRef(false) @@ -64,7 +65,7 @@ export function VideoEmbed({ const active = isGif || activeFromContext useEffect(() => { - if (!onScreen || impressionTrackedRef.current) return + if (!meaningfullyVisible || impressionTrackedRef.current) return impressionTrackedRef.current = true ax.metric('video:impression', { postUri: post?.uri, @@ -72,7 +73,7 @@ export function VideoEmbed({ context: 'embed', presentation: isGif ? 'gif' : 'video', }) - }, [ax, isGif, onScreen, post?.author.did, post?.uri]) + }, [ax, isGif, meaningfullyVisible, post?.author.did, post?.uri]) useEffect(() => { if (!ref.current) return @@ -81,7 +82,10 @@ export function VideoEmbed({ entries => { const entry = entries[0] if (!entry) return - setOnScreen(entry.isIntersecting && entry.intersectionRatio >= 0.5) + setOnScreen(entry.isIntersecting) + setMeaningfullyVisible( + entry.isIntersecting && entry.intersectionRatio >= 0.5, + ) // GIFs don't send position - they don't compete to be the active video if (!isGif) { sendPosition(