+ // The comment must be inserted not at the very beginning of the list,
+ // because the buildCommentsTree needs a correct path ordering.
+ // It should be inserted right after its parent is found
+ const comments = s.commentsRes.data.comments;
+ const newComment = res.data.comment_view;
+ const newCommentParentId = getCommentParentId(newComment.comment);
+
+ const foundCommentParentIndex = comments.findIndex(
+ c => c.comment.id === newCommentParentId,
+ );
+
+ comments.splice(foundCommentParentIndex + 1, 0, newComment);