diff --git a/app/javascript/components/Comments/Comment.tsx b/app/javascript/components/Comments/Comment.tsx index 30cc1dd1..737d9824 100644 --- a/app/javascript/components/Comments/Comment.tsx +++ b/app/javascript/components/Comments/Comment.tsx @@ -4,7 +4,7 @@ import NewComment from './NewComment'; import Separator from '../shared/Separator'; import { MutedText } from '../shared/CustomTexts'; -import { CommentRepliesState } from '../../reducers/commentRepliesReducer'; +import { ReplyFormState } from '../../reducers/replyFormReducer'; import friendlyDate from '../../helpers/friendlyDate'; @@ -14,7 +14,7 @@ interface Props { userFullName: string; updatedAt: string; - reply: CommentRepliesState; + replyForm: ReplyFormState; handleToggleCommentReply(): void; handleCommentReplyBodyChange(e: React.FormEvent): void; handleSubmitComment(body: string, parentId: number): void; @@ -29,7 +29,7 @@ const Comment = ({ userFullName, updatedAt, - reply, + replyForm, handleToggleCommentReply, handleCommentReplyBodyChange, handleSubmitComment, @@ -44,7 +44,7 @@ const Comment = ({

{body}

- { reply.isOpen ? 'Cancel' : 'Reply' } + { replyForm.isOpen ? 'Cancel' : 'Reply' } { isPowerUser ? @@ -59,11 +59,12 @@ const Comment = ({ {friendlyDate(updatedAt)}
{ - reply.isOpen ? + replyForm.isOpen ? ; - replies: Array; + replyForms: Array; parentId: number; level: number; @@ -21,7 +21,7 @@ interface Props { const CommentList = ({ comments, - replies, + replyForms, parentId, level, @@ -38,7 +38,7 @@ const CommentList = ({ return (
reply.commentId === comment.id)} + replyForm={replyForms.find(replyForm => replyForm.commentId === comment.id)} handleToggleCommentReply={() => toggleCommentReply(comment.id)} handleCommentReplyBodyChange={ (e: React.FormEvent) => ( @@ -54,7 +54,7 @@ const CommentList = ({ ; - replies: Array; + replyForms: Array; areLoading: boolean; error: string; @@ -50,7 +50,7 @@ class CommentsP extends React.Component { isPowerUser, comments, - replies, + replyForms, areLoading, error, @@ -58,7 +58,7 @@ class CommentsP extends React.Component { setCommentReplyBody, } = this.props; - const postReply = replies.find(reply => reply.commentId === -1); + const postReply = replyForms.find(replyForm => replyForm.commentId === null); return (
@@ -66,9 +66,10 @@ class CommentsP extends React.Component { body={postReply && postReply.body} parentId={null} isSubmitting={postReply && postReply.isSubmitting} + error={postReply && postReply.error} handleChange={ (e: React.FormEvent) => ( - setCommentReplyBody(-1, (e.target as HTMLTextAreaElement).value) + setCommentReplyBody(null, (e.target as HTMLTextAreaElement).value) ) } handleSubmit={this._handleSubmitComment} @@ -79,13 +80,13 @@ class CommentsP extends React.Component { { areLoading ? : null } { error ? {error} : null } - +
activity • {comments.length} comments - +
( -
- { - isLoggedIn ? - -