Skip to content

Commit 465f2ed

Browse files
author
Ajit Kumar
committed
fix(comments): ensure comment ID is set correctly and add success alert on deletion
1 parent 9630b43 commit 465f2ed

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

client/pages/plugin/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ function CommentsContainerAndForm({ plugin, listRef, user, id, userComment }) {
432432

433433
let $comment;
434434

435-
commentId = commentId || res.id;
435+
commentId = res.id;
436436
if (commentId) {
437437
userComment = await fetch(`/api/comment/${commentId}`).then((userRes) => userRes.json());
438438
$comment = tag.get(`#comment_${commentId}`);
@@ -469,6 +469,8 @@ function CommentsContainerAndForm({ plugin, listRef, user, id, userComment }) {
469469
try {
470470
const deleted = await deleteComment(commentId);
471471
if (!deleted) return;
472+
alert('SUCCESS', 'Comment deleted successfully');
473+
commentId = null;
472474
form.el.reset();
473475
for (const input of form.getAll('input[name=vote]')) {
474476
input.checked = false;

server/apis/comment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ router.post('/', async (req, res) => {
147147
}
148148

149149
const [row] = await Comment.get([Comment.ID, Comment.COMMENT, Comment.VOTE], [Comment.PLUGIN_ID, pluginId], [Comment.USER_ID, loggedInUser.id]);
150-
150+
151151
res.send({ message: 'Comment added', id: row.id, comment, vote });
152152
voteMessage = vote !== Comment.VOTE_NULL ? `${loggedInUser.name} voted ${Comment.getVoteString(vote)}` : '';
153153
commentMessage = comment ? `${loggedInUser.name} commented: ${comment}` : '';

0 commit comments

Comments
 (0)