Dont hide reply box on other actions. Fixes #1968 (#2189)

* Dont hide reply box on other actions. Fixes #1968

* Removing unecessary check.
This commit is contained in:
Dessalines 2023-10-19 11:35:53 -04:00 committed by GitHub
parent 68f0b654d4
commit bb8e4f26ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 9 deletions

View file

@ -195,7 +195,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
): void { ): void {
if (!deepEqual(this.props, nextProps)) { if (!deepEqual(this.props, nextProps)) {
this.setState({ this.setState({
showReply: false,
showEdit: false, showEdit: false,
showRemoveDialog: false, showRemoveDialog: false,
showBanDialog: false, showBanDialog: false,

View file

@ -699,7 +699,7 @@ export class Community extends Component<
async handleEditComment(form: EditComment) { async handleEditComment(form: EditComment) {
const editCommentRes = await HttpService.client.editComment(form); const editCommentRes = await HttpService.client.editComment(form);
this.findAndUpdateComment(editCommentRes); this.findAndUpdateCommentEdit(editCommentRes);
return editCommentRes; return editCommentRes;
} }
@ -889,7 +889,7 @@ export class Community extends Component<
} }
} }
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateCommentEdit(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment( s.commentsRes.data.comments = editComment(
@ -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>) { createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") { if (s.commentsRes.state === "success" && res.state === "success") {

View file

@ -931,7 +931,7 @@ export class Home extends Component<any, HomeState> {
async handleEditComment(form: EditComment) { async handleEditComment(form: EditComment) {
const editCommentRes = await HttpService.client.editComment(form); const editCommentRes = await HttpService.client.editComment(form);
this.findAndUpdateComment(editCommentRes); this.findAndUpdateCommentEdit(editCommentRes);
return editCommentRes; return editCommentRes;
} }
@ -1097,7 +1097,7 @@ export class Home extends Component<any, HomeState> {
} }
} }
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateCommentEdit(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment( s.commentsRes.data.comments = editComment(
@ -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>) { createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") { if (s.commentsRes.state === "success" && res.state === "success") {

View file

@ -845,7 +845,7 @@ export class Profile extends Component<
async handleEditComment(form: EditComment) { async handleEditComment(form: EditComment) {
const editCommentRes = await HttpService.client.editComment(form); const editCommentRes = await HttpService.client.editComment(form);
this.findAndUpdateComment(editCommentRes); this.findAndUpdateCommentEdit(editCommentRes);
return editCommentRes; return editCommentRes;
} }
@ -1009,7 +1009,7 @@ export class Profile extends Component<
} }
} }
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateCommentEdit(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.personRes.state === "success" && res.state === "success") { if (s.personRes.state === "success" && res.state === "success") {
s.personRes.data.comments = editComment( s.personRes.data.comments = editComment(
@ -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>) { createAndUpdateComments(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.personRes.state === "success" && res.state === "success") { if (s.personRes.state === "success" && res.state === "success") {

View file

@ -822,7 +822,7 @@ export class Post extends Component<any, PostState> {
async handleEditComment(form: EditComment) { async handleEditComment(form: EditComment) {
const editCommentRes = await HttpService.client.editComment(form); const editCommentRes = await HttpService.client.editComment(form);
this.findAndUpdateComment(editCommentRes); this.findAndUpdateCommentEdit(editCommentRes);
return editCommentRes; return editCommentRes;
} }
@ -1059,7 +1059,7 @@ export class Post extends Component<any, PostState> {
}); });
} }
findAndUpdateComment(res: RequestState<CommentResponse>) { findAndUpdateCommentEdit(res: RequestState<CommentResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") { if (s.commentsRes.state === "success" && res.state === "success") {
s.commentsRes.data.comments = editComment( s.commentsRes.data.comments = editComment(
@ -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>) { findAndUpdateCommentReply(res: RequestState<CommentReplyResponse>) {
this.setState(s => { this.setState(s => {
if (s.commentsRes.state === "success" && res.state === "success") { if (s.commentsRes.state === "success" && res.state === "success") {