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

Function BasePostModal

packages/shared/src/components/modals/BasePostModal.tsx:68–209  ·  view source on GitHub ↗
({
  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)

Source from the content-addressed store, hash-verified

66}
67
68function 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);

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected