feat: hide reply button for depth 3

This commit is contained in:
DIYgod
2022-10-22 02:15:13 +01:00
parent 42611ef635
commit b1b28fa592
2 changed files with 14 additions and 11 deletions
+1
View File
@@ -27,6 +27,7 @@ export const Comment: React.FC<{
originalId={page?.id}
comment={comment}
key={comment.transactionHash}
depth={0}
/>
))}
</div>
+13 -11
View File
@@ -20,15 +20,15 @@ export const CommentItem: React.FC<{
comment: NoteEntity & {
character?: CharacterEntity | null
}
isSub?: boolean
originalId?: string
}> = ({ comment, isSub, originalId }) => {
depth: number
}> = ({ comment, originalId, depth }) => {
const [replyOpen, setReplyOpen] = useState(false)
return (
<div
key={comment.transactionHash}
className={isSub ? "" : "border-b border-dashed pb-6"}
className={depth > 0 ? "" : "border-b border-dashed pb-6"}
>
<div className="flex group">
<UniLink
@@ -80,13 +80,15 @@ export const CommentItem: React.FC<{
size="sm"
pageId={`${comment.characterId}-${comment.noteId}`}
/>
<Button
className="text-gray-500 text-[13px] ml-2 mt-[-1px]"
variant="text"
onClick={() => setReplyOpen(!replyOpen)}
>
{replyOpen ? "Cancel" : "Reply"}
</Button>
{depth < 2 && (
<Button
className="text-gray-500 text-[13px] ml-2 mt-[-1px]"
variant="text"
onClick={() => setReplyOpen(!replyOpen)}
>
{replyOpen ? "Cancel" : "Reply"}
</Button>
)}
</div>
{replyOpen && (
<div className="pt-6">
@@ -109,7 +111,7 @@ export const CommentItem: React.FC<{
<CommentItem
comment={subcomment}
key={subcomment.transactionHash}
isSub={true}
depth={depth + 1}
/>
),
)}