mirror of https://github.com/vector-im/riot-web
Add ability to click-to-invite
parent
165adde0c8
commit
36616a97a1
|
@ -55,10 +55,23 @@ class MemberEntity extends Entity {
|
||||||
|
|
||||||
class UserEntity extends Entity {
|
class UserEntity extends Entity {
|
||||||
|
|
||||||
|
constructor(model, showInviteButton, inviteFn) {
|
||||||
|
super(model);
|
||||||
|
this.showInviteButton = Boolean(showInviteButton);
|
||||||
|
this.inviteFn = inviteFn;
|
||||||
|
}
|
||||||
|
|
||||||
|
onClick() {
|
||||||
|
if (this.inviteFn) {
|
||||||
|
this.inviteFn(this.model.userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getJsx() {
|
getJsx() {
|
||||||
var UserTile = sdk.getComponent("rooms.UserTile");
|
var UserTile = sdk.getComponent("rooms.UserTile");
|
||||||
return (
|
return (
|
||||||
<UserTile key={this.model.userId} user={this.model} />
|
<UserTile key={this.model.userId} user={this.model}
|
||||||
|
showInviteButton={this.showInviteButton} onClick={this.onClick.bind(this)} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +95,13 @@ module.exports = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {User[]} users
|
* @param {User[]} users
|
||||||
|
* @param {boolean} showInviteButton
|
||||||
|
* @param {Function} inviteFn Called with the user ID.
|
||||||
* @return {Entity[]}
|
* @return {Entity[]}
|
||||||
*/
|
*/
|
||||||
fromUsers: function(users) {
|
fromUsers: function(users, showInviteButton, inviteFn) {
|
||||||
return users.map(function(u) {
|
return users.map(function(u) {
|
||||||
return new UserEntity(u);
|
return new UserEntity(u, showInviteButton, inviteFn);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -320,11 +320,10 @@ module.exports = React.createClass({
|
||||||
// TODO: Cache this calculation
|
// TODO: Cache this calculation
|
||||||
var room = MatrixClientPeg.get().getRoom(this.props.roomId);
|
var room = MatrixClientPeg.get().getRoom(this.props.roomId);
|
||||||
var allUsers = MatrixClientPeg.get().getUsers();
|
var allUsers = MatrixClientPeg.get().getUsers();
|
||||||
// only add Users if they don't exist in the member list
|
// only add Users if they are not joined
|
||||||
allUsers = allUsers.filter(function(u) {
|
allUsers = allUsers.filter(function(u) {
|
||||||
return room.getMember(u.userId) === null;
|
return !room.hasMembershipState(u.userId, "join");
|
||||||
});
|
});
|
||||||
|
|
||||||
var SearchableEntityList = sdk.getComponent("rooms.SearchableEntityList");
|
var SearchableEntityList = sdk.getComponent("rooms.SearchableEntityList");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -332,9 +331,9 @@ module.exports = React.createClass({
|
||||||
onSubmit={this.onInvite}
|
onSubmit={this.onInvite}
|
||||||
entities={
|
entities={
|
||||||
Entities.fromRoomMembers(
|
Entities.fromRoomMembers(
|
||||||
room.currentState.getMembers() // ALLLLL OF THEM
|
room.getJoinedMembers()
|
||||||
).concat(
|
).concat(
|
||||||
Entities.fromUsers(allUsers)
|
Entities.fromUsers(allUsers, true, this.onInvite)
|
||||||
)
|
)
|
||||||
} />
|
} />
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue