From a7ea1931890dec4bc13bedfbb56d3b7857b0a885 Mon Sep 17 00:00:00 2001 From: wmwragg Date: Tue, 13 Sep 2016 10:29:17 +0100 Subject: [PATCH] A supplied roomId property, will make the dialog use that room for the invites, rather than creating a new one --- .../views/dialogs/ChatInviteDialog.js | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/components/views/dialogs/ChatInviteDialog.js b/src/components/views/dialogs/ChatInviteDialog.js index ce7ca0ff4d..be878aa670 100644 --- a/src/components/views/dialogs/ChatInviteDialog.js +++ b/src/components/views/dialogs/ChatInviteDialog.js @@ -37,6 +37,7 @@ module.exports = React.createClass({ ]), value: React.PropTypes.string, placeholder: React.PropTypes.string, + roomId: React.PropTypes.string, button: React.PropTypes.string, focus: React.PropTypes.bool, onFinished: React.PropTypes.func.isRequired @@ -189,19 +190,31 @@ module.exports = React.createClass({ }, _startChat: function(addr) { - // Start the chat - 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 user", - description: err.toString() - }); - return null; - }) - .done(); + if (this.props.roomId) { + Invite.inviteToRoom(this.props.roomId, addr).catch(function(err) { + var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createDialog(ErrorDialog, { + title: "Failure to invite user", + description: err.toString() + }); + return null; + }) + .done(); + } else { + // Start the chat + 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 user", + description: err.toString() + }); + return null; + }) + .done(); + } // Close - this will happen before the above, as that is async this.props.onFinished(true, addr);