Wire up invite button on the member list.
This commit is contained in:
parent
19ee75577e
commit
f2bd802bdc
4 changed files with 63 additions and 9 deletions
|
@ -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);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue