From dedaf0f5a2288705673a6cf70dd577519f37d8f3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 15 Feb 2019 12:36:54 +0100 Subject: [PATCH] disable lazy list rendering if extraTiles are provided --- src/components/structures/RoomSubList.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/structures/RoomSubList.js b/src/components/structures/RoomSubList.js index f7f74da728..d72f84b47f 100644 --- a/src/components/structures/RoomSubList.js +++ b/src/components/structures/RoomSubList.js @@ -282,7 +282,7 @@ const RoomSubList = React.createClass({ this.setState({scrollTop: this.refs.scroller.getScrollTop()}); }, - _getRenderItems: function() { + _getList: function() { // try our best to not create a new array // because LazyRenderList rerender when the items prop // is not the same object as the previous value @@ -296,6 +296,12 @@ const RoomSubList = React.createClass({ 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() { const len = this.props.list.length + this.props.extraTiles.length; const isCollapsed = this.state.hidden && !this.props.forceExpand; @@ -310,7 +316,7 @@ const RoomSubList = React.createClass({ return
{this._getHeaderJsx(isCollapsed)}
; - } else { + } else if (this._canUseLazyListRendering()) { return
{this._getHeaderJsx(isCollapsed)} @@ -319,7 +325,16 @@ const RoomSubList = React.createClass({ height={ this.state.scrollerHeight } renderItem={ this.makeRoomTile } itemHeight={34} - items={this._getRenderItems()} /> + items={ this.props.list } /> + +
; + } else { + const roomTiles = this.props.list.map(r => this.makeRoomTile(r)); + const tiles = roomTiles.concat(this.props.extraTiles); + return
+ {this._getHeaderJsx(isCollapsed)} + + { tiles }
; }