From 473486d05be8403f39ce1ccb54842ed17a68d964 Mon Sep 17 00:00:00 2001 From: Kaye Ena Crayzhel Misay Date: Wed, 29 Nov 2023 02:49:46 -0700 Subject: [PATCH] fix commenting bug --- client/src/components/post/MakeCommentModal.tsx | 10 +++++++--- client/src/components/post/post-item/PostPage.tsx | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/client/src/components/post/MakeCommentModal.tsx b/client/src/components/post/MakeCommentModal.tsx index 21f9486c..47db3ab2 100644 --- a/client/src/components/post/MakeCommentModal.tsx +++ b/client/src/components/post/MakeCommentModal.tsx @@ -155,6 +155,8 @@ const MakeCommentModal = ({ comment: comment, contentType: contentType, author: userData, + id: `${post.id}/comments/${authorId}`, + published: new Date(), }; const url = `${post.id}/comments/`; @@ -173,7 +175,7 @@ const MakeCommentModal = ({ post.count = post.count + 1; await fetchComments(); if (loggedUserId !== authorId) { - await sendCommentToInbox(comment, contentType, response.data["id"]); + await sendCommentToInbox(comment, contentType, response.data["id"], response.data["published"]); } } else { toast.error(ToastMessages.NOUSERCREDS); @@ -188,7 +190,7 @@ const MakeCommentModal = ({ post.count = post.count + 1; await fetchComments(); - await sendCommentToInbox(comment, contentType, response.data["id"]); + await sendCommentToInbox(comment, contentType, response.data["id"], response.data["published"]); } handleClear(); @@ -200,7 +202,8 @@ const MakeCommentModal = ({ const sendCommentToInbox = async ( comment: string, contentType: string, - id: string + id: string, + published: string, ) => { const data = { type: "comment", @@ -208,6 +211,7 @@ const MakeCommentModal = ({ id: id, comment: comment, contentType: contentType, + published: published, }; const url = `${post.author.id}/inbox/`; diff --git a/client/src/components/post/post-item/PostPage.tsx b/client/src/components/post/post-item/PostPage.tsx index 6d01a789..16b11931 100644 --- a/client/src/components/post/post-item/PostPage.tsx +++ b/client/src/components/post/post-item/PostPage.tsx @@ -198,6 +198,8 @@ const PostPage = () => { comment: comment, contentType: contentType, author: userData, + id: `${post.id}/comments/${authorId}`, + published: new Date(), }; const url = `${post.id}/comments/`; @@ -217,7 +219,7 @@ const PostPage = () => { post.count = post.count + 1; await fetchComments(post.id, post.author.host); if (loggedUserId !== authorId) { - await sendCommentToInbox(comment, contentType, response.data["id"], post.author.id); + await sendCommentToInbox(comment, contentType, response.data["id"], post.author.id, response.data["published"]); } } else { toast.error(ToastMessages.NOUSERCREDS); @@ -232,7 +234,7 @@ const PostPage = () => { post.count = post.count + 1; await fetchComments(post.id, post.author.host); - await sendCommentToInbox(comment, contentType, response.data["id"], post.author.id); + await sendCommentToInbox(comment, contentType, response.data["id"], post.author.id, response.data["published"]); } handleClear(); @@ -246,6 +248,7 @@ const PostPage = () => { contentType: string, commentId: string, authorUrlId: string, + published: string, ) => { const data = { type: "comment", @@ -253,6 +256,7 @@ const PostPage = () => { id: commentId, comment: comment, contentType: contentType, + published: published, }; const url = `${authorUrlId}/inbox/`;