({
className,
children,
isLoading,
postType,
source,
loadingClassName,
postPosition,
onPreviousPost,
onNextPost,
navigationLeadingContent,
navigationCustomActions,
navigationContainerClassName,
navigationHideSubscribeAction,
navigationRedesign,
loadingChildren,
post,
onRequestClose,
size = Modal.Size.XLarge,
...props
}: BasePostModalProps)
| 42 | } |
| 43 | |
| 44 | function BasePostModal({ |
| 45 | className, |
| 46 | children, |
| 47 | isLoading, |
| 48 | postType, |
| 49 | source, |
| 50 | loadingClassName, |
| 51 | postPosition, |
| 52 | onPreviousPost, |
| 53 | onNextPost, |
| 54 | navigationLeadingContent, |
| 55 | navigationCustomActions, |
| 56 | navigationContainerClassName, |
| 57 | navigationHideSubscribeAction, |
| 58 | navigationRedesign, |
| 59 | loadingChildren, |
| 60 | post, |
| 61 | onRequestClose, |
| 62 | size = Modal.Size.XLarge, |
| 63 | ...props |
| 64 | }: BasePostModalProps): ReactElement { |
| 65 | const usePostReferrer = |
| 66 | usePostReferrerContext()?.usePostReferrer ?? (() => {}); |
| 67 | const { logEvent } = useLogContext(); |
| 68 | const [scrollNode, setScrollNode] = useState<HTMLDivElement | null>(null); |
| 69 | const { getCreativeForTags } = useEngagementAdsContext(); |
| 70 | |
| 71 | usePostReferrer({ post }); |
| 72 | |
| 73 | const onScroll = useCallback( |
| 74 | (event?: Event) => { |
| 75 | if (!post?.id || !event) { |
| 76 | return; |
| 77 | } |
| 78 | const targetElement = event.target as HTMLElement; |
| 79 | logEvent({ |
| 80 | event_name: LogEvent.PageScroll, |
| 81 | target_type: TargetType.Post, |
| 82 | target_id: post.id, |
| 83 | extra: JSON.stringify({ |
| 84 | scrollTop: targetElement.scrollTop, |
| 85 | }), |
| 86 | }); |
| 87 | }, |
| 88 | [logEvent, post?.id], |
| 89 | ); |
| 90 | |
| 91 | const [debouncedOnScroll] = useDebounceFn(onScroll, 100); |
| 92 | useEventListener(scrollNode, 'scroll', debouncedOnScroll); |
| 93 | |
| 94 | return ( |
| 95 | <ActivePostContextProvider post={post}> |
| 96 | <LogExtraContextProvider |
| 97 | selector={() => { |
| 98 | const creative = getCreativeForTags(post?.tags || []); |
| 99 | return { |
| 100 | referrer_target_id: post?.id, |
| 101 | referrer_target_type: post?.id ? TargetType.Post : undefined, |
nothing calls this directly
no test coverage detected