A supplied roomId property, will make the dialog use that room for the invites, rather than creating a new one

pull/21833/head
wmwragg 2016-09-13 10:29:17 +01:00
parent 0f720dd6b8
commit a7ea193189
1 changed files with 26 additions and 13 deletions

View File

@ -37,6 +37,7 @@ module.exports = React.createClass({
]), ]),
value: React.PropTypes.string, value: React.PropTypes.string,
placeholder: React.PropTypes.string, placeholder: React.PropTypes.string,
roomId: React.PropTypes.string,
button: React.PropTypes.string, button: React.PropTypes.string,
focus: React.PropTypes.bool, focus: React.PropTypes.bool,
onFinished: React.PropTypes.func.isRequired onFinished: React.PropTypes.func.isRequired
@ -189,19 +190,31 @@ module.exports = React.createClass({
}, },
_startChat: function(addr) { _startChat: function(addr) {
// Start the chat if (this.props.roomId) {
createRoom().then(function(roomId) { Invite.inviteToRoom(this.props.roomId, addr).catch(function(err) {
return Invite.inviteToRoom(roomId, addr); var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
}) Modal.createDialog(ErrorDialog, {
.catch(function(err) { title: "Failure to invite user",
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); description: err.toString()
Modal.createDialog(ErrorDialog, { });
title: "Failure to invite user", return null;
description: err.toString() })
}); .done();
return null; } else {
}) // Start the chat
.done(); 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 // Close - this will happen before the above, as that is async
this.props.onFinished(true, addr); this.props.onFinished(true, addr);