disable lazy list rendering if extraTiles are provided
This commit is contained in:
parent
321dd49db4
commit
dedaf0f5a2
1 changed files with 18 additions and 3 deletions
|
@ -282,7 +282,7 @@ const RoomSubList = React.createClass({
|
||||||
this.setState({scrollTop: this.refs.scroller.getScrollTop()});
|
this.setState({scrollTop: this.refs.scroller.getScrollTop()});
|
||||||
},
|
},
|
||||||
|
|
||||||
_getRenderItems: function() {
|
_getList: function() {
|
||||||
// try our best to not create a new array
|
// try our best to not create a new array
|
||||||
// because LazyRenderList rerender when the items prop
|
// because LazyRenderList rerender when the items prop
|
||||||
// is not the same object as the previous value
|
// is not the same object as the previous value
|
||||||
|
@ -296,6 +296,12 @@ const RoomSubList = React.createClass({
|
||||||
return list.concat(extraTiles);
|
return list.concat(extraTiles);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_canUseLazyListRendering() {
|
||||||
|
// for now disable lazy rendering as they are already rendered tiles
|
||||||
|
// not rooms like props.list we pass to LazyRenderList
|
||||||
|
return !this.props.extraTiles || !this.props.extraTiles.length;
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const len = this.props.list.length + this.props.extraTiles.length;
|
const len = this.props.list.length + this.props.extraTiles.length;
|
||||||
const isCollapsed = this.state.hidden && !this.props.forceExpand;
|
const isCollapsed = this.state.hidden && !this.props.forceExpand;
|
||||||
|
@ -310,7 +316,7 @@ const RoomSubList = React.createClass({
|
||||||
return <div ref="subList" className={subListClasses}>
|
return <div ref="subList" className={subListClasses}>
|
||||||
{this._getHeaderJsx(isCollapsed)}
|
{this._getHeaderJsx(isCollapsed)}
|
||||||
</div>;
|
</div>;
|
||||||
} else {
|
} else if (this._canUseLazyListRendering()) {
|
||||||
return <div ref="subList" className={subListClasses}>
|
return <div ref="subList" className={subListClasses}>
|
||||||
{this._getHeaderJsx(isCollapsed)}
|
{this._getHeaderJsx(isCollapsed)}
|
||||||
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
||||||
|
@ -319,7 +325,16 @@ const RoomSubList = React.createClass({
|
||||||
height={ this.state.scrollerHeight }
|
height={ this.state.scrollerHeight }
|
||||||
renderItem={ this.makeRoomTile }
|
renderItem={ this.makeRoomTile }
|
||||||
itemHeight={34}
|
itemHeight={34}
|
||||||
items={this._getRenderItems()} />
|
items={ this.props.list } />
|
||||||
|
</IndicatorScrollbar>
|
||||||
|
</div>;
|
||||||
|
} else {
|
||||||
|
const roomTiles = this.props.list.map(r => this.makeRoomTile(r));
|
||||||
|
const tiles = roomTiles.concat(this.props.extraTiles);
|
||||||
|
return <div ref="subList" className={subListClasses}>
|
||||||
|
{this._getHeaderJsx(isCollapsed)}
|
||||||
|
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
||||||
|
{ tiles }
|
||||||
</IndicatorScrollbar>
|
</IndicatorScrollbar>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue