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

Function SubComment

packages/shared/src/components/comments/SubComment.tsx:31–149  ·  view source on GitHub ↗
({
  comment,
  parentComment,
  className,
  onCommented,
  isModalThread = false,
  isFirst = false,
  isLast = false,
  extendTopConnector = false,
  canReply = true,
  onReplyBlocked,
  forceInlineComposer = false,
  ...props
}: SubCommentProps)

Source from the content-addressed store, hash-verified

29}
30
31function SubComment({
32 comment,
33 parentComment,
34 className,
35 onCommented,
36 isModalThread = false,
37 isFirst = false,
38 isLast = false,
39 extendTopConnector = false,
40 canReply = true,
41 onReplyBlocked,
42 forceInlineComposer = false,
43 ...props
44}: SubCommentProps): ReactElement {
45 const { inputProps, commentId, onReplyTo } = useComments(props.post);
46 const { inputProps: editProps, onEdit } = useEditCommentProps();
47
48 return (
49 <>
50 {!editProps && (
51 <CommentBox
52 {...props}
53 key={comment.id}
54 parentId={parentComment.id}
55 comment={comment}
56 onEdit={({ id, lastUpdatedAt }) =>
57 onEdit({
58 commentId: id,
59 lastUpdatedAt,
60 parentCommentId: parentComment.id,
61 })
62 }
63 className={{
64 container: classNames(
65 'relative',
66 isModalThread &&
67 'rounded-none bg-transparent px-0 py-2 hover:bg-transparent',
68 isModalThread && !isLast && 'mb-1',
69 ),
70 content: classNames('ml-[52px]', isModalThread && 'mt-1'),
71 markdown: classNames(
72 isModalThread &&
73 '!text-[0.9375rem] [&_a]:!text-[0.9375rem] [&_li]:!text-[0.9375rem] [&_li]:!leading-[1.55] [&_p]:!text-[0.9375rem] [&_p]:!leading-[1.55]',
74 ),
75 }}
76 onComment={(selected, parent) => {
77 if (!canReply) {
78 onReplyBlocked?.();
79 return;
80 }
81
82 onReplyTo({
83 username: comment.author?.username ?? null,
84 parentCommentId: parent,
85 commentId: selected.id,
86 });
87 }}
88 isModalThread={isModalThread}

Callers

nothing calls this directly

Calls 4

useCommentsFunction · 0.90
useEditCommentPropsFunction · 0.90
onEditFunction · 0.50
onCommentedFunction · 0.50

Tested by

no test coverage detected