({
className,
children,
isLoading,
source,
loadingClassName,
postPosition,
onPreviousPost,
onNextPost,
navigationLeadingContent,
navigationCustomActions,
navigationContainerClassName,
navigationHideSubscribeAction,
navigationContentOwnsActions,
isHybrid = false,
onReadArticle,
loadingChildren,
post,
onRequestClose,
size = Modal.Size.XLarge,
...props
}: BasePostModalProps)
| 66 | } |
| 67 | |
| 68 | function BasePostModal({ |
| 69 | className, |
| 70 | children, |
| 71 | isLoading, |
| 72 | source, |
| 73 | loadingClassName, |
| 74 | postPosition, |
| 75 | onPreviousPost, |
| 76 | onNextPost, |
| 77 | navigationLeadingContent, |
| 78 | navigationCustomActions, |
| 79 | navigationContainerClassName, |
| 80 | navigationHideSubscribeAction, |
| 81 | navigationContentOwnsActions, |
| 82 | isHybrid = false, |
| 83 | onReadArticle, |
| 84 | loadingChildren, |
| 85 | post, |
| 86 | onRequestClose, |
| 87 | size = Modal.Size.XLarge, |
| 88 | ...props |
| 89 | }: BasePostModalProps): ReactElement { |
| 90 | const usePostReferrer = |
| 91 | usePostReferrerContext()?.usePostReferrer ?? (() => {}); |
| 92 | const { logEvent } = useLogContext(); |
| 93 | const [scrollNode, setScrollNode] = useState<HTMLDivElement | null>(null); |
| 94 | const { getCreativeForTags } = useEngagementAdsContext(); |
| 95 | const { post: loadedPost } = usePostById({ id: post?.id ?? '' }); |
| 96 | const activePost = useMemo( |
| 97 | () => |
| 98 | post && loadedPost?.source |
| 99 | ? { ...post, source: loadedPost.source } |
| 100 | : post, |
| 101 | [post, loadedPost?.source], |
| 102 | ); |
| 103 | |
| 104 | usePostReferrer({ post }); |
| 105 | |
| 106 | const onScroll = useCallback( |
| 107 | (event?: Event) => { |
| 108 | if (!post?.id || !event) { |
| 109 | return; |
| 110 | } |
| 111 | const targetElement = event.target as HTMLElement; |
| 112 | logEvent({ |
| 113 | event_name: LogEvent.PageScroll, |
| 114 | target_type: TargetType.Post, |
| 115 | target_id: post.id, |
| 116 | extra: JSON.stringify({ |
| 117 | scrollTop: targetElement.scrollTop, |
| 118 | }), |
| 119 | }); |
| 120 | }, |
| 121 | [logEvent, post?.id], |
| 122 | ); |
| 123 | |
| 124 | const [debouncedOnScroll] = useDebounceFn(onScroll, 100); |
| 125 | useEventListener(scrollNode, 'scroll', debouncedOnScroll); |
nothing calls this directly
no test coverage detected