Skip to content

Commit

Permalink
fix: submit reply bug
Browse files Browse the repository at this point in the history
  • Loading branch information
521xueweihan committed Apr 16, 2024
1 parent f9cc44b commit d4fc833
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ yarn-error.log*
# next-sitemap
robots.txt
sitemap.xml
sitemap-*.xml
sitemap-*.xml

.plandex/
14 changes: 4 additions & 10 deletions src/components/respository/CommentContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,19 @@ const CommentContainer = (props: Props) => {
<CommentItem
className='mb-6'
{...item}
key={item.cid}
key={`reply-item-${item.cid}`}
onReply={(_, reply_id) => setCommentId(reply_id)}
onChangeVote={(value) => handleChangeVote(index, value)}
/>

{item.reply_id === commentId && (
<CommentSubmit
replyUser={item}
key={item.reply_id}
belongId={belongId}
onCancelReply={() => setCommentId(undefined)}
onSuccess={() => {
replyList[item.cid].length > 0
? loadMoreReply(item.cid)
: refreshList();

setCommentId(undefined);
refreshList();
}}
/>
)}
Expand All @@ -116,7 +112,7 @@ const CommentContainer = (props: Props) => {
<CommentItem
className='mb-6'
{...item}
key={item.cid}
key={`commet-item-${item.cid}`}
onReply={(cid) => setCommentId(cid)}
onChangeVote={(value) => handleChangeVote(index, value)}
/>
Expand Down Expand Up @@ -148,13 +144,11 @@ const CommentContainer = (props: Props) => {
cIndex: number;
}) => {
if (!item.replies) return null;

const list = replyList[item.cid] || item.replies.data;

return (
<div className='pl-8 md:pl-16'>
{list.map((reply) => (
<CommentWrapper key={item.reply_id} item={reply} index={cIndex} />
<CommentWrapper key={reply.reply_id} item={reply} index={cIndex} />
))}

{item.replies.has_more && item.replies.total > list.length && (
Expand Down
2 changes: 2 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ svg {
.hidden-scrollbar::-webkit-scrollbar {
/* 隐藏默认的滚动条 */
-webkit-appearance: none;
display: none;
width: 0px;
}

/* 自定义滚动条 */
.custom-scrollbar::-webkit-scrollbar {
/* 隐藏默认的滚动条 */
-webkit-appearance: none;
display: none;
}

.custom-scrollbar::-webkit-scrollbar {
Expand Down

0 comments on commit d4fc833

Please sign in to comment.