From 3d66dff0aa80eb8264328f3e99c91e7b7c74e4e8 Mon Sep 17 00:00:00 2001 From: wmwragg Date: Mon, 5 Sep 2016 14:16:21 +0100 Subject: [PATCH] Basic ChatInviteDialog functionality - Creates new room, and tries to invite the address typed into the text box, and reports errors, if any --- .../views/dialogs/ChatInviteDialog.js | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/components/views/dialogs/ChatInviteDialog.js b/src/components/views/dialogs/ChatInviteDialog.js index 3cf734da63..07dc3e7809 100644 --- a/src/components/views/dialogs/ChatInviteDialog.js +++ b/src/components/views/dialogs/ChatInviteDialog.js @@ -15,10 +15,13 @@ limitations under the License. */ var React = require("react"); -var sdk = require('../../../index'); +var sdk = require("../../../index"); +var Invite = require("../../../Invite"); +var createRoom = require("../../../createRoom"); +var Modal = require('../../../Modal'); module.exports = React.createClass({ - displayName: 'ChatInviteDialog', + displayName: "ChatInviteDialog", propTypes: { title: React.PropTypes.string, description: React.PropTypes.oneOfType([ @@ -48,8 +51,24 @@ module.exports = React.createClass({ } }, - onOk: function() { - this.props.onFinished(true, this.refs.textinput.value); + onStartChat: function() { + this._startChat(this.refs.textinput.value); + }, + + _startChat: function(addr) { + createRoom().then(function(roomId) { + return Invite.inviteToRoom(roomId, addr); + }) + .catch(function(err) { + var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createDialog(ErrorDialog, { + title: "Failure to invite " + addr, + description: err.toString() + }); + return null; + }) + .done(); + this.props.onFinished(true, addr); }, onCancel: function() { @@ -65,12 +84,12 @@ module.exports = React.createClass({ else if (e.keyCode === 13) { // enter e.stopPropagation(); e.preventDefault(); - this.props.onFinished(true, this.refs.textinput.value); + this._startChat(this.refs.textinput.value); } }, render: function() { - var TintableSvg = sdk.getComponent('elements.TintableSvg'); + var TintableSvg = sdk.getComponent("elements.TintableSvg"); return (
@@ -88,7 +107,7 @@ module.exports = React.createClass({
-