({
className,
comment,
appendTooltipTo,
joinNotificationCommentId,
onCommented,
lazy = false,
logImpression,
logClick,
isModalThread = false,
canReply = true,
onReplyBlocked,
forceInlineComposer = false,
repliesLocked = false,
onLockedRepliesClick,
...props
}: MainCommentProps)
| 73 | false)); |
| 74 | |
| 75 | export 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; |
nothing calls this directly
no test coverage detected