Separate fetching indicator state
This commit is contained in:
parent
008e8d4f54
commit
9b08f4d11f
1 changed files with 27 additions and 25 deletions
|
@ -35,8 +35,9 @@ export default withMatrixClient(React.createClass({
|
|||
getInitialState: function() {
|
||||
return {
|
||||
fetching: false,
|
||||
fetchingInvitedMembers: false,
|
||||
members: null,
|
||||
invited_members: null,
|
||||
invitedMembers: null,
|
||||
truncateAt: INITIAL_LOAD_NUM_MEMBERS,
|
||||
};
|
||||
},
|
||||
|
@ -47,7 +48,10 @@ export default withMatrixClient(React.createClass({
|
|||
},
|
||||
|
||||
_fetchMembers: function() {
|
||||
this.setState({fetching: true});
|
||||
this.setState({
|
||||
fetching: true,
|
||||
fetchingInvitedMembers: true,
|
||||
});
|
||||
this.props.matrixClient.getGroupUsers(this.props.groupId).then((result) => {
|
||||
this.setState({
|
||||
members: result.chunk.map((apiMember) => {
|
||||
|
@ -62,13 +66,13 @@ export default withMatrixClient(React.createClass({
|
|||
|
||||
this.props.matrixClient.getGroupInvitedUsers(this.props.groupId).then((result) => {
|
||||
this.setState({
|
||||
invited_members: result.chunk.map((apiMember) => {
|
||||
invitedMembers: result.chunk.map((apiMember) => {
|
||||
return groupMemberFromApiObject(apiMember);
|
||||
}),
|
||||
fetching: false,
|
||||
fetchingInvitedMembers: false,
|
||||
});
|
||||
}).catch((e) => {
|
||||
this.setState({fetching: false});
|
||||
this.setState({fetchingInvitedMembers: false});
|
||||
console.error("Failed to get group invited member list: " + e);
|
||||
});
|
||||
},
|
||||
|
@ -98,6 +102,7 @@ export default withMatrixClient(React.createClass({
|
|||
|
||||
makeGroupMemberTiles: function(query, memberList) {
|
||||
const GroupMemberTile = sdk.getComponent("groups.GroupMemberTile");
|
||||
const TruncatedList = sdk.getComponent("elements.TruncatedList");
|
||||
query = (query || "").toLowerCase();
|
||||
if (query) {
|
||||
memberList = memberList.filter((m) => {
|
||||
|
@ -129,17 +134,19 @@ export default withMatrixClient(React.createClass({
|
|||
}
|
||||
});
|
||||
|
||||
return memberList;
|
||||
return <TruncatedList className="mx_MemberList_wrapper" truncateAt={this.state.truncateAt}
|
||||
createOverflowElement={this._createOverflowTile}
|
||||
>
|
||||
{ memberList }
|
||||
</TruncatedList>;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
if (this.state.fetching) {
|
||||
if (this.state.fetching || this.state.fetchingInvitedMembers) {
|
||||
const Spinner = sdk.getComponent("elements.Spinner");
|
||||
return (<div className="mx_MemberList">
|
||||
<Spinner />
|
||||
</div>);
|
||||
} else if (this.state.members === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const inputBox = (
|
||||
|
@ -150,26 +157,21 @@ export default withMatrixClient(React.createClass({
|
|||
</form>
|
||||
);
|
||||
|
||||
const TruncatedList = sdk.getComponent("elements.TruncatedList");
|
||||
const joined = this.state.members ? <div className="mx_MemberList_joined">
|
||||
{ this.makeGroupMemberTiles(this.state.searchQuery, this.state.members) }
|
||||
</div> : <div />;
|
||||
|
||||
const invited = this.state.invitedMembers ? <div className="mx_MemberList_invited">
|
||||
<h2>{ _t("Invited") }</h2>
|
||||
{ this.makeGroupMemberTiles(this.state.searchQuery, this.state.invitedMembers) }
|
||||
</div> : <div />;
|
||||
|
||||
return (
|
||||
<div className="mx_MemberList">
|
||||
{ inputBox }
|
||||
<GeminiScrollbar autoshow={true} className="mx_MemberList_outerWrapper">
|
||||
<div className="mx_MemberList_joined">
|
||||
<TruncatedList className="mx_MemberList_wrapper" truncateAt={this.state.truncateAt}
|
||||
createOverflowElement={this._createOverflowTile}>
|
||||
{ this.makeGroupMemberTiles(this.state.searchQuery, this.state.members) }
|
||||
</TruncatedList>
|
||||
</div>
|
||||
<div className="mx_MemberList_invited">
|
||||
<h2>{ _t("Invited") }</h2>
|
||||
<div className="mx_MemberList_wrapper">
|
||||
<TruncatedList truncateAt={this.state.truncateAt}
|
||||
createOverflowElement={this._createOverflowTile}>
|
||||
{ this.makeGroupMemberTiles(this.state.searchQuery, this.state.invited_members) }
|
||||
</TruncatedList>
|
||||
</div>
|
||||
</div>
|
||||
{ joined }
|
||||
{ invited }
|
||||
</GeminiScrollbar>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue