mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 11:21:32 +00:00
Fixing comment edits stalling. Fixes #846
This commit is contained in:
parent
96f133750d
commit
208c17dcc8
1 changed files with 13 additions and 8 deletions
21
ui/src/components/comment-form.tsx
vendored
21
ui/src/components/comment-form.tsx
vendored
|
@ -245,7 +245,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFinished(data: CommentResponse) {
|
handleFinished(op: UserOperation, data: CommentResponse) {
|
||||||
let isReply =
|
let isReply =
|
||||||
this.props.node !== undefined && data.comment.parent_id !== null;
|
this.props.node !== undefined && data.comment.parent_id !== null;
|
||||||
let xor =
|
let xor =
|
||||||
|
@ -253,11 +253,16 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(data.comment.creator_id == UserService.Instance.user.id &&
|
(data.comment.creator_id == UserService.Instance.user.id &&
|
||||||
// If its a reply, make sure parent child match
|
((op == UserOperation.CreateComment &&
|
||||||
isReply &&
|
// If its a reply, make sure parent child match
|
||||||
data.comment.parent_id == this.props.node.comment.id) ||
|
isReply &&
|
||||||
// Otherwise, check the XOR of the two
|
data.comment.parent_id == this.props.node.comment.id) ||
|
||||||
(!isReply && xor)
|
// Otherwise, check the XOR of the two
|
||||||
|
(!isReply && xor))) ||
|
||||||
|
// If its a comment edit, only check that its from your user, and that its a
|
||||||
|
// text edit only
|
||||||
|
|
||||||
|
(op == UserOperation.EditComment && data.comment.content)
|
||||||
) {
|
) {
|
||||||
this.state.previewMode = false;
|
this.state.previewMode = false;
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
|
@ -373,10 +378,10 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
|
||||||
if (UserService.Instance.user) {
|
if (UserService.Instance.user) {
|
||||||
if (res.op == UserOperation.CreateComment) {
|
if (res.op == UserOperation.CreateComment) {
|
||||||
let data = res.data as CommentResponse;
|
let data = res.data as CommentResponse;
|
||||||
this.handleFinished(data);
|
this.handleFinished(res.op, data);
|
||||||
} else if (res.op == UserOperation.EditComment) {
|
} else if (res.op == UserOperation.EditComment) {
|
||||||
let data = res.data as CommentResponse;
|
let data = res.data as CommentResponse;
|
||||||
this.handleFinished(data);
|
this.handleFinished(res.op, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue