Added an inviteList state to hold all the users to invite, but currently pretend it only has one users (the first one)

This commit is contained in:
wmwragg 2016-09-12 14:48:00 +01:00
parent 7d58968ea6
commit d538377b82

View file

@ -55,8 +55,7 @@ module.exports = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {
user: null, inviteList: [],
addressSelected: false,
queryList: [], queryList: [],
}; };
}, },
@ -73,8 +72,8 @@ module.exports = React.createClass({
var addr; var addr;
// Either an address tile was created, or text input is being used // Either an address tile was created, or text input is being used
if (this.state.user) { if (this.state.inviteList[0]) {
addr = this.state.user.userId; addr = this.state.inviteList[0].userId;
} else { } else {
addr = this.refs.textinput.value; addr = this.refs.textinput.value;
} }
@ -141,8 +140,7 @@ module.exports = React.createClass({
onDismissed: function() { onDismissed: function() {
this.setState({ this.setState({
user: null, inviteList: [],
addressSelected: false,
queryList: [], queryList: [],
}); });
}, },
@ -150,18 +148,15 @@ module.exports = React.createClass({
onClick: function(index) { onClick: function(index) {
var self = this; var self = this;
return function() { return function() {
self.setState({ self.onSelected(index);
user: self.state.queryList[index],
addressSelected: true,
queryList: [],
});
}; };
}, },
onSelected: function(index) { onSelected: function(index) {
var inviteList = this.state.inviteList.slice();
inviteList.push(this.state.queryList[index]);
this.setState({ this.setState({
user: this.state.queryList[index], inviteList: inviteList,
addressSelected: true,
queryList: [], queryList: [],
}); });
}, },
@ -237,10 +232,10 @@ module.exports = React.createClass({
this.scrollElement = null; this.scrollElement = null;
var query; var query;
if (this.state.addressSelected) { if (this.state.inviteList.length > 0) {
var AddressTile = sdk.getComponent("elements.AddressTile"); var AddressTile = sdk.getComponent("elements.AddressTile");
query = ( query = (
<AddressTile user={this.state.user} canDismiss={true} onDismissed={this.onDismissed} /> <AddressTile user={this.state.inviteList[0]} canDismiss={true} onDismissed={this.onDismissed} />
); );
} else { } else {
query = ( query = (