mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-01 08:57:35 +03:00
Factor out common onSendMessageFailed
This commit is contained in:
parent
5da6ca8fc1
commit
70190be65c
2 changed files with 17 additions and 24 deletions
|
@ -40,6 +40,7 @@ import * as HtmlUtils from '../../../HtmlUtils';
|
||||||
import Autocomplete from './Autocomplete';
|
import Autocomplete from './Autocomplete';
|
||||||
import {Completion} from "../../../autocomplete/Autocompleter";
|
import {Completion} from "../../../autocomplete/Autocompleter";
|
||||||
import Markdown from '../../../Markdown';
|
import Markdown from '../../../Markdown';
|
||||||
|
import {onSendMessageFailed} from './MessageComposerInputOld';
|
||||||
|
|
||||||
const TYPING_USER_TIMEOUT = 10000, TYPING_SERVER_TIMEOUT = 30000;
|
const TYPING_USER_TIMEOUT = 10000, TYPING_SERVER_TIMEOUT = 30000;
|
||||||
|
|
||||||
|
@ -553,21 +554,11 @@ export default class MessageComposerInput extends React.Component {
|
||||||
sendMessagePromise = sendTextFn.call(this.client, this.props.room.roomId, contentText);
|
sendMessagePromise = sendTextFn.call(this.client, this.props.room.roomId, contentText);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessagePromise.then((res) => {
|
sendMessagePromise.done((res) => {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'message_sent',
|
action: 'message_sent',
|
||||||
});
|
});
|
||||||
}, (err) => {
|
}, onSendMessageFailed);
|
||||||
if (err.name === "UnknownDeviceError") {
|
|
||||||
var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog");
|
|
||||||
Modal.createDialog(UnknownDeviceDialog, {
|
|
||||||
devices: err.devices
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'message_send_failed',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
editorState: this.createEditorState(),
|
editorState: this.createEditorState(),
|
||||||
|
|
|
@ -29,10 +29,22 @@ var TYPING_USER_TIMEOUT = 10000;
|
||||||
var TYPING_SERVER_TIMEOUT = 30000;
|
var TYPING_SERVER_TIMEOUT = 30000;
|
||||||
var MARKDOWN_ENABLED = true;
|
var MARKDOWN_ENABLED = true;
|
||||||
|
|
||||||
|
export function onSendMessageFailed(err) {
|
||||||
|
if (err.name === "UnknownDeviceError") {
|
||||||
|
const UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog");
|
||||||
|
Modal.createDialog(UnknownDeviceDialog, {
|
||||||
|
devices: err.devices,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'message_send_failed',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The textInput part of the MessageComposer
|
* The textInput part of the MessageComposer
|
||||||
*/
|
*/
|
||||||
module.exports = React.createClass({
|
export default React.createClass({
|
||||||
displayName: 'MessageComposerInput',
|
displayName: 'MessageComposerInput',
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
|
@ -341,18 +353,8 @@ module.exports = React.createClass({
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'message_sent'
|
action: 'message_sent'
|
||||||
});
|
});
|
||||||
}, function(err) {
|
}, onSendMessageFailed);
|
||||||
if (err.name === "UnknownDeviceError") {
|
|
||||||
var UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog");
|
|
||||||
Modal.createDialog(UnknownDeviceDialog, {
|
|
||||||
devices: err.devices
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'message_send_failed'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
this.refs.textarea.value = '';
|
this.refs.textarea.value = '';
|
||||||
this.resizeInput();
|
this.resizeInput();
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
Loading…
Reference in a new issue