({
post,
origin,
sortBy,
isComposerOpen = false,
onShare,
onClickUpvote,
modalParentSelector,
joinNotificationCommentId,
className = {},
onCommented,
removeSpacing = false,
canReply,
onReplyBlocked,
forceInlineComposer,
interleaveEvery,
renderInterleaved,
teaser = false,
onTeaserSignup,
}: PostCommentsProps)
| 68 | const noopShowUpvotes = (): void => {}; |
| 69 | |
| 70 | export function PostComments({ |
| 71 | post, |
| 72 | origin, |
| 73 | sortBy, |
| 74 | isComposerOpen = false, |
| 75 | onShare, |
| 76 | onClickUpvote, |
| 77 | modalParentSelector, |
| 78 | joinNotificationCommentId, |
| 79 | className = {}, |
| 80 | onCommented, |
| 81 | removeSpacing = false, |
| 82 | canReply, |
| 83 | onReplyBlocked, |
| 84 | forceInlineComposer, |
| 85 | interleaveEvery, |
| 86 | renderInterleaved, |
| 87 | teaser = false, |
| 88 | onTeaserSignup, |
| 89 | }: PostCommentsProps): ReactElement { |
| 90 | const { id } = post; |
| 91 | const container = useRef<HTMLDivElement | null>(null); |
| 92 | const isModalThread = threadCommentOrigins.has(origin); |
| 93 | const { |
| 94 | queryKey, |
| 95 | comments, |
| 96 | isLoading: isLoadingComments, |
| 97 | commentsCount, |
| 98 | } = usePostComments({ postId: id, sortBy }); |
| 99 | |
| 100 | useCommentContentPreferenceMutationSubscription({ queryKey }); |
| 101 | |
| 102 | const commentRef = useRef<HTMLElement | null>(null); |
| 103 | const { deleteComment } = useDeleteComment(); |
| 104 | const { commentHash } = useScrollToHashComment({ |
| 105 | containerRef: container, |
| 106 | commentRef, |
| 107 | postId: id, |
| 108 | enabled: !isLoadingComments && commentsCount > 0, |
| 109 | }); |
| 110 | |
| 111 | const containerClassName = classNames( |
| 112 | 'flex flex-col gap-4', |
| 113 | !isModalThread && '-mx-4 mobileL:mx-0', |
| 114 | !removeSpacing && [ |
| 115 | 'mb-12', |
| 116 | isModalThread && (isComposerOpen ? 'mt-2' : 'mt-5'), |
| 117 | !isModalThread && 'mt-6', |
| 118 | ], |
| 119 | ); |
| 120 | // Tablet and laptop pin the teaser's footer over the end of the post |
| 121 | // card; the card keeps that much room below the skeleton. |
| 122 | const teaserContainerClassName = classNames( |
| 123 | containerClassName, |
| 124 | 'tablet:!mb-44', |
| 125 | ); |
| 126 | const teaserSkeleton = teaser && ( |
| 127 | <CommentsTeaserSkeleton |
nothing calls this directly
no test coverage detected