Skip to content

Commit b156b2d

Browse files
yyyortCopilot
andauthored
Apply suggestions from code review
copilot code improvement suggestion Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 6a4fdad commit b156b2d

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎apps/codebility/app/home/feeds/_components/PostViewCommentItem.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export default function PostViewCommentItem({
2525

2626
const handleDelete = async () => {
2727
setIsVisible(false);
28-
await deletePostComment(commenntId);
28+
try {
29+
await deletePostComment(commenntId);
30+
} catch (error) {
31+
setIsVisible(true);
32+
// Optionally, you could log the error or show a message to the user
33+
}
2934
};
3035

3136
if (!isVisible) return null;

‎apps/codebility/app/home/feeds/_components/PostViewCreateComment.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ export default function PostViewCreateComment({
2222

2323
const handleKeyDown = async (e: React.KeyboardEvent<HTMLInputElement>) => {
2424
if (e.key === "Enter" && comment.trim() && !isSubmitting) {
25+
if (!user || !user.id) return;
2526
try {
2627
setIsSubmitting(true);
27-
await createComment(postId, user?.id!, comment);
28+
await createComment(postId, user.id, comment);
2829
setComment("");
2930
onCommentCreated?.();
3031
} finally {

0 commit comments

Comments
 (0)