pass membersLoaded state to TimelinePanel to force it to re-render

... once the members are loaded.
This commit is contained in:
Bruno Windels 2018-09-17 19:27:25 +02:00
parent 473f2dd72b
commit 0ce7bb8995

View file

@ -91,13 +91,16 @@ module.exports = React.createClass({
}, },
getInitialState: function() { getInitialState: function() {
const llMembers = MatrixClientPeg.get().hasLazyLoadMembersEnabled();
return { return {
room: null, room: null,
roomId: null, roomId: null,
roomLoading: true, roomLoading: true,
peekLoading: false, peekLoading: false,
shouldPeek: true, shouldPeek: true,
// used to trigger a rerender in TimelinePanel once the members are loaded,
// so RR are rendered again (now with the members available), ...
membersLoaded: !llMembers,
// The event to be scrolled to initially // The event to be scrolled to initially
initialEventId: null, initialEventId: null,
// The offset in pixels from the event with which to scroll vertically // The offset in pixels from the event with which to scroll vertically
@ -593,7 +596,7 @@ module.exports = React.createClass({
try { try {
await room.loadMembersIfNeeded(); await room.loadMembersIfNeeded();
if (!this.unmounted) { if (!this.unmounted) {
this.forceUpdate(); this.setState({membersLoaded: true});
} }
} catch(err) { } catch(err) {
const errorMessage = `Fetching room members for ${room.roomId} failed.` + const errorMessage = `Fetching room members for ${room.roomId} failed.` +
@ -1765,6 +1768,7 @@ module.exports = React.createClass({
onReadMarkerUpdated={this._updateTopUnreadMessagesBar} onReadMarkerUpdated={this._updateTopUnreadMessagesBar}
showUrlPreview = {this.state.showUrlPreview} showUrlPreview = {this.state.showUrlPreview}
className="mx_RoomView_messagePanel" className="mx_RoomView_messagePanel"
membersLoaded={this.state.membersLoaded}
/>); />);
let topUnreadMessagesBar = null; let topUnreadMessagesBar = null;