From bb8e4f26eec18dd01857c09ff8b2798370c5bec4 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 19 Oct 2023 11:35:53 -0400 Subject: [PATCH] Dont hide reply box on other actions. Fixes #1968 (#2189) * Dont hide reply box on other actions. Fixes #1968 * Removing unecessary check. --- src/shared/components/comment/comment-node.tsx | 1 - src/shared/components/community/community.tsx | 16 ++++++++++++++-- src/shared/components/home/home.tsx | 16 ++++++++++++++-- src/shared/components/person/profile.tsx | 16 ++++++++++++++-- src/shared/components/post/post.tsx | 17 +++++++++++++++-- 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index aabe9a91..00f57dc9 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -195,7 +195,6 @@ export class CommentNode extends Component { ): void { if (!deepEqual(this.props, nextProps)) { this.setState({ - showReply: false, showEdit: false, showRemoveDialog: false, showBanDialog: false, diff --git a/src/shared/components/community/community.tsx b/src/shared/components/community/community.tsx index 01ceb128..8f3c0bb5 100644 --- a/src/shared/components/community/community.tsx +++ b/src/shared/components/community/community.tsx @@ -699,7 +699,7 @@ export class Community extends Component< async handleEditComment(form: EditComment) { const editCommentRes = await HttpService.client.editComment(form); - this.findAndUpdateComment(editCommentRes); + this.findAndUpdateCommentEdit(editCommentRes); return editCommentRes; } @@ -889,7 +889,7 @@ export class Community extends Component< } } - findAndUpdateComment(res: RequestState) { + findAndUpdateCommentEdit(res: RequestState) { this.setState(s => { if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editComment( @@ -902,6 +902,18 @@ export class Community extends Component< }); } + findAndUpdateComment(res: RequestState) { + this.setState(s => { + if (s.commentsRes.state === "success" && res.state === "success") { + s.commentsRes.data.comments = editComment( + res.data.comment_view, + s.commentsRes.data.comments, + ); + } + return s; + }); + } + createAndUpdateComments(res: RequestState) { this.setState(s => { if (s.commentsRes.state === "success" && res.state === "success") { diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index eaa4d775..257f46c7 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -931,7 +931,7 @@ export class Home extends Component { async handleEditComment(form: EditComment) { const editCommentRes = await HttpService.client.editComment(form); - this.findAndUpdateComment(editCommentRes); + this.findAndUpdateCommentEdit(editCommentRes); return editCommentRes; } @@ -1097,7 +1097,7 @@ export class Home extends Component { } } - findAndUpdateComment(res: RequestState) { + findAndUpdateCommentEdit(res: RequestState) { this.setState(s => { if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editComment( @@ -1110,6 +1110,18 @@ export class Home extends Component { }); } + findAndUpdateComment(res: RequestState) { + this.setState(s => { + if (s.commentsRes.state === "success" && res.state === "success") { + s.commentsRes.data.comments = editComment( + res.data.comment_view, + s.commentsRes.data.comments, + ); + } + return s; + }); + } + createAndUpdateComments(res: RequestState) { this.setState(s => { if (s.commentsRes.state === "success" && res.state === "success") { diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index 6a92c6c9..37477105 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -845,7 +845,7 @@ export class Profile extends Component< async handleEditComment(form: EditComment) { const editCommentRes = await HttpService.client.editComment(form); - this.findAndUpdateComment(editCommentRes); + this.findAndUpdateCommentEdit(editCommentRes); return editCommentRes; } @@ -1009,7 +1009,7 @@ export class Profile extends Component< } } - findAndUpdateComment(res: RequestState) { + findAndUpdateCommentEdit(res: RequestState) { this.setState(s => { if (s.personRes.state === "success" && res.state === "success") { s.personRes.data.comments = editComment( @@ -1022,6 +1022,18 @@ export class Profile extends Component< }); } + findAndUpdateComment(res: RequestState) { + this.setState(s => { + if (s.personRes.state === "success" && res.state === "success") { + s.personRes.data.comments = editComment( + res.data.comment_view, + s.personRes.data.comments, + ); + } + return s; + }); + } + createAndUpdateComments(res: RequestState) { this.setState(s => { if (s.personRes.state === "success" && res.state === "success") { diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 8f9bd59e..519bff48 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -822,7 +822,7 @@ export class Post extends Component { async handleEditComment(form: EditComment) { const editCommentRes = await HttpService.client.editComment(form); - this.findAndUpdateComment(editCommentRes); + this.findAndUpdateCommentEdit(editCommentRes); return editCommentRes; } @@ -1059,7 +1059,7 @@ export class Post extends Component { }); } - findAndUpdateComment(res: RequestState) { + findAndUpdateCommentEdit(res: RequestState) { this.setState(s => { if (s.commentsRes.state === "success" && res.state === "success") { s.commentsRes.data.comments = editComment( @@ -1072,6 +1072,19 @@ export class Post extends Component { }); } + // No need to set finished on a comment vote, save, etc + findAndUpdateComment(res: RequestState) { + this.setState(s => { + if (s.commentsRes.state === "success" && res.state === "success") { + s.commentsRes.data.comments = editComment( + res.data.comment_view, + s.commentsRes.data.comments, + ); + } + return s; + }); + } + findAndUpdateCommentReply(res: RequestState) { this.setState(s => { if (s.commentsRes.state === "success" && res.state === "success") {