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

Commit dedaf0f

Browse files
committed
disable lazy list rendering if extraTiles are provided
1 parent 321dd49 commit dedaf0f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/components/structures/RoomSubList.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ const RoomSubList = React.createClass({
282282
this.setState({scrollTop: this.refs.scroller.getScrollTop()});
283283
},
284284

285-
_getRenderItems: function() {
285+
_getList: function() {
286286
// try our best to not create a new array
287287
// because LazyRenderList rerender when the items prop
288288
// is not the same object as the previous value
@@ -296,6 +296,12 @@ const RoomSubList = React.createClass({
296296
return list.concat(extraTiles);
297297
},
298298

299+
_canUseLazyListRendering() {
300+
// for now disable lazy rendering as they are already rendered tiles
301+
// not rooms like props.list we pass to LazyRenderList
302+
return !this.props.extraTiles || !this.props.extraTiles.length;
303+
},
304+
299305
render: function() {
300306
const len = this.props.list.length + this.props.extraTiles.length;
301307
const isCollapsed = this.state.hidden && !this.props.forceExpand;
@@ -310,7 +316,7 @@ const RoomSubList = React.createClass({
310316
return <div ref="subList" className={subListClasses}>
311317
{this._getHeaderJsx(isCollapsed)}
312318
</div>;
313-
} else {
319+
} else if (this._canUseLazyListRendering()) {
314320
return <div ref="subList" className={subListClasses}>
315321
{this._getHeaderJsx(isCollapsed)}
316322
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
@@ -319,7 +325,16 @@ const RoomSubList = React.createClass({
319325
height={ this.state.scrollerHeight }
320326
renderItem={ this.makeRoomTile }
321327
itemHeight={34}
322-
items={this._getRenderItems()} />
328+
items={ this.props.list } />
329+
</IndicatorScrollbar>
330+
</div>;
331+
} else {
332+
const roomTiles = this.props.list.map(r => this.makeRoomTile(r));
333+
const tiles = roomTiles.concat(this.props.extraTiles);
334+
return <div ref="subList" className={subListClasses}>
335+
{this._getHeaderJsx(isCollapsed)}
336+
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
337+
{ tiles }
323338
</IndicatorScrollbar>
324339
</div>;
325340
}

0 commit comments

Comments
 (0)