Wire up invite button on the member list.

This commit is contained in:
Kegan Dougal 2015-07-20 15:07:19 +01:00
parent 19ee75577e
commit f2bd802bdc
4 changed files with 63 additions and 9 deletions

View file

@ -55,11 +55,16 @@ module.exports = {
return this.state.value;
},
setValue: function(val) {
setValue: function(val, shouldSubmit, suppressListener) {
var self = this;
this.setState({
value: val,
phase: this.Phases.Display,
}, this.onValueChanged);
}, function() {
if (!suppressListener) {
self.onValueChanged(shouldSubmit);
}
});
},
edit: function() {
@ -74,7 +79,7 @@ module.exports = {
});
},
onValueChanged: function() {
this.props.onValueChanged(this.state.value);
onValueChanged: function(shouldSubmit) {
this.props.onValueChanged(this.state.value, shouldSubmit);
},
};

View file

@ -61,6 +61,32 @@ module.exports = {
});
},
onInvite: function(inputText) {
var self = this;
// sanity check the input
inputText = inputText.trim(); // react requires es5-shim so we know trim() exists
if (inputText[0] !== '@' || inputText.indexOf(":") === -1) {
console.error("Bad user ID to invite: %s", inputText);
return;
}
self.setState({
inviting: true
});
console.log("Invite %s to %s", inputText, this.props.roomId);
MatrixClientPeg.get().invite(this.props.roomId, inputText).done(
function(res) {
console.log("Invited");
self.setState({
inviting: false
});
}, function(err) {
console.error("Failed to invite: %s", JSON.stringify(err));
self.setState({
inviting: false
});
});
},
roomMembers: function(limit) {
if (!this.props.roomId) return {};
var cli = MatrixClientPeg.get();