Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Show spinner in member list while loading members #2139

Merged
merged 3 commits into from
Sep 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 46 additions & 12 deletions src/components/views/rooms/MemberList.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@ module.exports = React.createClass({

getInitialState: function() {
this.memberDict = this.getMemberDict();
const members = this.roomMembers();

return {
members: members,
filteredJoinedMembers: this._filterMembers(members, 'join'),
filteredInvitedMembers: this._filterMembers(members, 'invite'),

// ideally we'd size this to the page height, but
// in practice I find that a little constraining
truncateAtJoined: INITIAL_LOAD_NUM_MEMBERS,
truncateAtInvited: INITIAL_LOAD_NUM_INVITED,
searchQuery: "",
};
const cli = MatrixClientPeg.get();
if (cli.hasLazyLoadMembersEnabled()) {
return {loading: true};
} else {
return this._getMembersState();
}
},

componentWillMount: function() {
Expand All @@ -69,6 +63,14 @@ module.exports = React.createClass({
}
},

componentDidMount: async function() {
const cli = MatrixClientPeg.get();
if (cli.hasLazyLoadMembersEnabled()) {
await this._waitForMembersToLoad();
this.setState(this._getMembersState());
}
},

componentWillUnmount: function() {
const cli = MatrixClientPeg.get();
if (cli) {
Expand All @@ -84,6 +86,33 @@ module.exports = React.createClass({
this._updateList.cancelPendingCall();
},

_waitForMembersToLoad: async function() {
if (!this.props.roomId) return {};
const cli = MatrixClientPeg.get();
const room = cli.getRoom(this.props.roomId);
if (room) {
await room.loadMembersIfNeeded();
}
},

_getMembersState: function() {
const members = this.roomMembers();
// set the state after determining _showPresence to make sure it's
// taken into account while rerendering
return {
loading: false,
members: members,
filteredJoinedMembers: this._filterMembers(members, 'join'),
filteredInvitedMembers: this._filterMembers(members, 'invite'),

// ideally we'd size this to the page height, but
// in practice I find that a little constraining
truncateAtJoined: INITIAL_LOAD_NUM_MEMBERS,
truncateAtInvited: INITIAL_LOAD_NUM_INVITED,
searchQuery: "",
};
},

/*
onRoomTimeline: function(ev, room, toStartOfTimeline, removed, data) {
// ignore anything but real-time updates at the end of the room:
Expand Down Expand Up @@ -393,6 +422,11 @@ module.exports = React.createClass({
},

render: function() {
if (this.state.loading) {
const Spinner = sdk.getComponent("elements.Spinner");
return <div className="mx_MemberList"><Spinner /></div>;
}

const TruncatedList = sdk.getComponent("elements.TruncatedList");
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");

Expand Down