diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js index a7ac9fb1..22fd712d 100644 --- a/src/components/views/dialogs/DevtoolsDialog.js +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -29,11 +29,14 @@ class SendCustomEvent extends React.Component { super(props, context); this._send = this._send.bind(this); this.onBack = this.onBack.bind(this); - } + this._onChange = this._onChange.bind(this); - state = { - message: null, - }; + this.state = { + message: null, + input_eventType: '', + input_evContent: '{\n\n}', + }; + } onBack() { if (this.state.message) { @@ -51,13 +54,18 @@ class SendCustomEvent extends React.Component { } send(content) { - return MatrixClientPeg.get().sendEvent(this.props.roomId, this.refs.eventType.value, content); + return MatrixClientPeg.get().sendEvent(this.props.roomId, this.state.input_eventType, content); } async _send() { + if (this.state.input_eventType === '') { + this.setState({ message: _t('You must specify an event type!') }); + return; + } + let message; try { - const content = JSON.parse(this.refs.evContent.value); + const content = JSON.parse(this.state.input_evContent); await this.send(content); message = _t('Event sent!'); } catch (e) { @@ -67,7 +75,11 @@ class SendCustomEvent extends React.Component { } _additionalFields() { - return
; + return
; + } + + _onChange(e) { + this.setState({[`input_${e.target.id}`]: e.target.value}); } render() { @@ -87,14 +99,14 @@ class SendCustomEvent extends React.Component {
- +
-