Skip to content

Commit

Permalink
Dont hide reply box on other actions. Fixes #1968 (#2189)
Browse files Browse the repository at this point in the history
* Dont hide reply box on other actions. Fixes #1968

* Removing unecessary check.
  • Loading branch information
dessalines authored Oct 19, 2023
1 parent 68f0b65 commit bb8e4f2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/shared/components/comment/comment-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
): void {
if (!deepEqual(this.props, nextProps)) {
this.setState({
showReply: false,
showEdit: false,
showRemoveDialog: false,
showBanDialog: false,
Expand Down
16 changes: 14 additions & 2 deletions src/shared/components/community/community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -889,7 +889,7 @@ export class Community extends Component<
}
}

findAndUpdateComment(res: RequestState<CommentResponse>) {
findAndUpdateCommentEdit(res: RequestState<CommentResponse>) {
this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment(
Expand All @@ -902,6 +902,18 @@ export class Community extends Component<
});
}

findAndUpdateComment(res: RequestState<CommentResponse>) {
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<CommentResponse>) {
this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") {
Expand Down
16 changes: 14 additions & 2 deletions src/shared/components/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ export class Home extends Component<any, HomeState> {

async handleEditComment(form: EditComment) {
const editCommentRes = await HttpService.client.editComment(form);
this.findAndUpdateComment(editCommentRes);
this.findAndUpdateCommentEdit(editCommentRes);

return editCommentRes;
}
Expand Down Expand Up @@ -1097,7 +1097,7 @@ export class Home extends Component<any, HomeState> {
}
}

findAndUpdateComment(res: RequestState<CommentResponse>) {
findAndUpdateCommentEdit(res: RequestState<CommentResponse>) {
this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment(
Expand All @@ -1110,6 +1110,18 @@ export class Home extends Component<any, HomeState> {
});
}

findAndUpdateComment(res: RequestState<CommentResponse>) {
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<CommentResponse>) {
this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") {
Expand Down
16 changes: 14 additions & 2 deletions src/shared/components/person/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1009,7 +1009,7 @@ export class Profile extends Component<
}
}

findAndUpdateComment(res: RequestState<CommentResponse>) {
findAndUpdateCommentEdit(res: RequestState<CommentResponse>) {
this.setState(s => {
if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.comments = editComment(
Expand All @@ -1022,6 +1022,18 @@ export class Profile extends Component<
});
}

findAndUpdateComment(res: RequestState<CommentResponse>) {
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<CommentResponse>) {
this.setState(s => {
if (s.personRes.state === "success" && res.state === "success") {
Expand Down
17 changes: 15 additions & 2 deletions src/shared/components/post/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ export class Post extends Component<any, PostState> {

async handleEditComment(form: EditComment) {
const editCommentRes = await HttpService.client.editComment(form);
this.findAndUpdateComment(editCommentRes);
this.findAndUpdateCommentEdit(editCommentRes);

return editCommentRes;
}
Expand Down Expand Up @@ -1059,7 +1059,7 @@ export class Post extends Component<any, PostState> {
});
}

findAndUpdateComment(res: RequestState<CommentResponse>) {
findAndUpdateCommentEdit(res: RequestState<CommentResponse>) {
this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment(
Expand All @@ -1072,6 +1072,19 @@ export class Post extends Component<any, PostState> {
});
}

// No need to set finished on a comment vote, save, etc
findAndUpdateComment(res: RequestState<CommentResponse>) {
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<CommentReplyResponse>) {
this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") {
Expand Down

0 comments on commit bb8e4f2

Please sign in to comment.