mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 23:43:28 +00:00
Fix bug where UI breaks trying to send a DM (#2452)
This commit is contained in:
parent
ef72c75000
commit
b0a711a4ac
|
@ -47,6 +47,8 @@ export class PrivateMessageForm extends Component<
|
||||||
super(props, context);
|
super(props, context);
|
||||||
|
|
||||||
this.handleContentChange = this.handleContentChange.bind(this);
|
this.handleContentChange = this.handleContentChange.bind(this);
|
||||||
|
this.handlePrivateMessageSubmit =
|
||||||
|
this.handlePrivateMessageSubmit.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(
|
componentWillReceiveProps(
|
||||||
|
@ -118,9 +120,7 @@ export class PrivateMessageForm extends Component<
|
||||||
</label>
|
</label>
|
||||||
<div className="col-sm-10">
|
<div className="col-sm-10">
|
||||||
<MarkdownTextArea
|
<MarkdownTextArea
|
||||||
onSubmit={event => {
|
onSubmit={this.handlePrivateMessageSubmit}
|
||||||
this.handlePrivateMessageSubmit(this, event);
|
|
||||||
}}
|
|
||||||
initialContent={this.state.content}
|
initialContent={this.state.content}
|
||||||
onContentChange={this.handleContentChange}
|
onContentChange={this.handleContentChange}
|
||||||
allLanguages={[]}
|
allLanguages={[]}
|
||||||
|
@ -140,20 +140,19 @@ export class PrivateMessageForm extends Component<
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePrivateMessageSubmit(i: PrivateMessageForm, event: any) {
|
handlePrivateMessageSubmit() {
|
||||||
event.preventDefault();
|
this.setState({ loading: true, submitted: true });
|
||||||
i.setState({ loading: true, submitted: true });
|
const pm = this.props.privateMessageView;
|
||||||
const pm = i.props.privateMessageView;
|
const content = this.state.content ?? "";
|
||||||
const content = i.state.content ?? "";
|
|
||||||
if (pm) {
|
if (pm) {
|
||||||
i.props.onEdit?.({
|
this.props.onEdit?.({
|
||||||
private_message_id: pm.private_message.id,
|
private_message_id: pm.private_message.id,
|
||||||
content,
|
content,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
i.props.onCreate?.({
|
this.props.onCreate?.({
|
||||||
content,
|
content,
|
||||||
recipient_id: i.props.recipient.id,
|
recipient_id: this.props.recipient.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue