avoid .done and .then anti-pattern

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2018-05-01 18:14:35 +01:00
parent 11ae0805b0
commit db55f87699
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E
2 changed files with 6 additions and 6 deletions

View file

@ -914,14 +914,12 @@ module.exports = React.createClass({
return;
}
ContentMessages.sendContentToRoom(
file, this.state.room.roomId, MatrixClientPeg.get(),
).done(() => {
ContentMessages.sendContentToRoom(file, this.state.room.roomId, MatrixClientPeg.get()).then(() => {
// Send message_sent callback, for things like _checkIfAlone because after all a file is still a message.
dis.dispatch({
action: 'message_sent',
});
}, (error) => {
}).catch((error) => {
if (error.name === "UnknownDeviceError") {
// Let the status bar handle this
return;

View file

@ -877,11 +877,13 @@ export default class MessageComposerInput extends React.Component {
}
this.client.sendMessage(this.props.room.roomId, content).done((res) => {
this.client.sendMessage(this.props.room.roomId, content).then((res) => {
dis.dispatch({
action: 'message_sent',
});
}, (e) => onSendMessageFailed(e, this.props.room));
}).catch((e) => {
onSendMessageFailed(e, this.props.room);
});
this.setState({
editorState: this.createEditorState(),