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

Function MainComment

packages/shared/src/components/comments/MainComment.tsx:63–288  ·  view source on GitHub ↗
({
  className,
  comment,
  appendTooltipTo,
  permissionNotificationCommentId,
  joinNotificationCommentId,
  onCommented,
  lazy = false,
  logImpression,
  logClick,
  isModalThread = false,
  ...props
}: MainCommentProps)

Source from the content-addressed store, hash-verified

61 false));
62
63export default function MainComment({
64 className,
65 comment,
66 appendTooltipTo,
67 permissionNotificationCommentId,
68 joinNotificationCommentId,
69 onCommented,
70 lazy = false,
71 logImpression,
72 logClick,
73 isModalThread = false,
74 ...props
75}: MainCommentProps): ReactElement {
76 const { user } = useContext(AuthContext);
77 const { logEvent } = useLogContext();
78 const showNotificationPermissionBanner = useMemo(
79 () => shouldShowBannerOnComment(permissionNotificationCommentId, comment),
80 [permissionNotificationCommentId, comment],
81 );
82 const [isJoinSquadBannerDismissed] = usePersistentContext(
83 SQUAD_COMMENT_JOIN_BANNER_KEY,
84 false,
85 );
86 const showJoinSquadBanner =
87 useMemo(
88 () => shouldShowBannerOnComment(joinNotificationCommentId, comment),
89 [joinNotificationCommentId, comment],
90 ) &&
91 !props.post.source?.currentMember &&
92 !isJoinSquadBannerDismissed;
93
94 const {
95 commentId,
96 inputProps: replyProps,
97 onReplyTo,
98 } = useComments(props.post);
99 const { inputProps: editProps, onEdit } = useEditCommentProps();
100 const commentChildren = comment.children?.edges ?? [];
101 const replyCount = commentChildren.length;
102
103 const initialInView = !lazy;
104 const { ref: inViewRef, inView } = useInView({
105 triggerOnce: true,
106 initialInView,
107 });
108
109 const [areRepliesExpanded, setAreRepliesExpanded] = useState(true);
110 const showThreadRepliesToggle = isModalThread && replyCount > 0;
111
112 const onClick = () => {
113 if (!logClick && !props.linkToComment) {
114 return;
115 }
116
117 logEvent({
118 event_name: LogEvent.Click,
119 target_type: TargetType.Comment,
120 target_id: comment.id,

Callers

nothing calls this directly

Calls 8

useLogContextFunction · 0.90
useCommentsFunction · 0.90
useEditCommentPropsFunction · 0.90
usePersistentContextFunction · 0.85
useInViewFunction · 0.85
onEditFunction · 0.85
onCommentedFunction · 0.85

Tested by

no test coverage detected