Skip to content

Commit

Permalink
fix commenting bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kaynzhel committed Nov 29, 2023
1 parent 9db69ab commit 473486d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions client/src/components/post/MakeCommentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/`;
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -200,14 +202,16 @@ const MakeCommentModal = ({
const sendCommentToInbox = async (
comment: string,
contentType: string,
id: string
id: string,
published: string,
) => {
const data = {
type: "comment",
author: userData,
id: id,
comment: comment,
contentType: contentType,
published: published,
};

const url = `${post.author.id}/inbox/`;
Expand Down
8 changes: 6 additions & 2 deletions client/src/components/post/post-item/PostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/`;
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -246,13 +248,15 @@ const PostPage = () => {
contentType: string,
commentId: string,
authorUrlId: string,
published: string,
) => {
const data = {
type: "comment",
author: userData,
id: commentId,
comment: comment,
contentType: contentType,
published: published,
};

const url = `${authorUrlId}/inbox/`;
Expand Down

0 comments on commit 473486d

Please sign in to comment.