Merge pull request #635 from matrix-org/matthew/warn-unknown-devices

very barebones support for warning users when rooms contain unknown devices
This commit is contained in:
Matthew Hodgson 2017-02-02 18:08:18 +00:00 committed by GitHub
commit e45ac36a3b
6 changed files with 141 additions and 16 deletions

View file

@ -40,6 +40,7 @@ import * as HtmlUtils from '../../../HtmlUtils';
import Autocomplete from './Autocomplete';
import {Completion} from "../../../autocomplete/Autocompleter";
import Markdown from '../../../Markdown';
import {onSendMessageFailed} from './MessageComposerInputOld';
const TYPING_USER_TIMEOUT = 10000, TYPING_SERVER_TIMEOUT = 30000;
@ -553,15 +554,11 @@ export default class MessageComposerInput extends React.Component {
sendMessagePromise = sendTextFn.call(this.client, this.props.room.roomId, contentText);
}
sendMessagePromise.then(() => {
sendMessagePromise.done((res) => {
dis.dispatch({
action: 'message_sent',
});
}, () => {
dis.dispatch({
action: 'message_send_failed',
});
});
}, onSendMessageFailed);
this.setState({
editorState: this.createEditorState(),

View file

@ -29,10 +29,22 @@ var TYPING_USER_TIMEOUT = 10000;
var TYPING_SERVER_TIMEOUT = 30000;
var MARKDOWN_ENABLED = true;
export function onSendMessageFailed(err) {
if (err.name === "UnknownDeviceError") {
const UnknownDeviceDialog = sdk.getComponent("dialogs.UnknownDeviceDialog");
Modal.createDialog(UnknownDeviceDialog, {
devices: err.devices,
}, "mx_Dialog_unknownDevice");
}
dis.dispatch({
action: 'message_send_failed',
});
}
/*
* The textInput part of the MessageComposer
*/
module.exports = React.createClass({
export default React.createClass({
displayName: 'MessageComposerInput',
statics: {
@ -337,15 +349,12 @@ module.exports = React.createClass({
MatrixClientPeg.get().sendTextMessage(this.props.room.roomId, contentText);
}
sendMessagePromise.done(function() {
sendMessagePromise.done(function(res) {
dis.dispatch({
action: 'message_sent'
});
}, function() {
dis.dispatch({
action: 'message_send_failed'
});
});
}, onSendMessageFailed);
this.refs.textarea.value = '';
this.resizeInput();
ev.preventDefault();