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

Function MainComment

packages/shared/src/components/comments/MainComment.tsx:75–310  ·  view source on GitHub ↗
({
  className,
  comment,
  appendTooltipTo,
  joinNotificationCommentId,
  onCommented,
  lazy = false,
  logImpression,
  logClick,
  isModalThread = false,
  canReply = true,
  onReplyBlocked,
  forceInlineComposer = false,
  repliesLocked = false,
  onLockedRepliesClick,
  ...props
}: MainCommentProps)

Source from the content-addressed store, hash-verified

73 false));
74
75export default function MainComment({
76 className,
77 comment,
78 appendTooltipTo,
79 joinNotificationCommentId,
80 onCommented,
81 lazy = false,
82 logImpression,
83 logClick,
84 isModalThread = false,
85 canReply = true,
86 onReplyBlocked,
87 forceInlineComposer = false,
88 repliesLocked = false,
89 onLockedRepliesClick,
90 ...props
91}: MainCommentProps): ReactElement {
92 const { logEvent } = useLogContext();
93 const [isJoinSquadBannerDismissed] = usePersistentContext(
94 SQUAD_COMMENT_JOIN_BANNER_KEY,
95 false,
96 );
97 const showJoinSquadBanner =
98 useMemo(
99 () => shouldShowBannerOnComment(joinNotificationCommentId, comment),
100 [joinNotificationCommentId, comment],
101 ) &&
102 !props.post.source?.currentMember &&
103 !isJoinSquadBannerDismissed;
104
105 const {
106 commentId,
107 inputProps: replyProps,
108 onReplyTo,
109 } = useComments(props.post);
110 const { inputProps: editProps, onEdit } = useEditCommentProps();
111 const commentChildren = comment.children?.edges ?? [];
112 const replyCount = commentChildren.length;
113
114 const [initialInView] = useState(
115 () => !lazy || renderedCommentIds.has(comment.id),
116 );
117 const { ref: inViewRef, inView } = useInView({
118 triggerOnce: true,
119 initialInView,
120 skip: initialInView,
121 });
122
123 useEffect(() => {
124 if (inView) {
125 renderedCommentIds.add(comment.id);
126 }
127 }, [inView, comment.id]);
128
129 const [isExpanded, setIsExpanded] = useState(true);
130 const areRepliesExpanded = !repliesLocked && isExpanded;
131 const showThreadRepliesToggle =
132 isModalThread && replyCount > 0 && !repliesLocked;

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected