MCPcopy Create free account
hub / github.com/dailydotdev/apps / BasePostModal

Function BasePostModal

packages/shared/src/components/modals/BasePostModal.tsx:44–153  ·  view source on GitHub ↗
({
  className,
  children,
  isLoading,
  postType,
  source,
  loadingClassName,
  postPosition,
  onPreviousPost,
  onNextPost,
  navigationLeadingContent,
  navigationCustomActions,
  navigationContainerClassName,
  navigationHideSubscribeAction,
  navigationRedesign,
  loadingChildren,
  post,
  onRequestClose,
  size = Modal.Size.XLarge,
  ...props
}: BasePostModalProps)

Source from the content-addressed store, hash-verified

42}
43
44function 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,

Callers

nothing calls this directly

Calls 6

useLogContextFunction · 0.90
useEngagementAdsContextFunction · 0.90
useEventListenerFunction · 0.90
getEngagementLogExtraFunction · 0.90
logEventFunction · 0.85
useDebounceFnFunction · 0.85

Tested by

no test coverage detected