diff --git a/src/components/structures/RoomSubList.js b/src/components/structures/RoomSubList.js index 3d09c05c43..60be1d7b34 100644 --- a/src/components/structures/RoomSubList.js +++ b/src/components/structures/RoomSubList.js @@ -57,8 +57,8 @@ const RoomSubList = createReactClass({ onHeaderClick: PropTypes.func, incomingCall: PropTypes.object, isFiltered: PropTypes.bool, - headerItems: PropTypes.node, // content shown in the sublist header extraTiles: PropTypes.arrayOf(PropTypes.node), // extra elements added beneath tiles + forceExpand: PropTypes.bool, }, getInitialState: function() { @@ -299,21 +299,20 @@ const RoomSubList = createReactClass({ render: function() { const len = this.props.list.length + this.props.extraTiles.length; const isCollapsed = this.state.hidden && !this.props.forceExpand; - if (len) { - const subListClasses = classNames({ - "mx_RoomSubList": true, - "mx_RoomSubList_hidden": isCollapsed, - "mx_RoomSubList_nonEmpty": len && !isCollapsed, - }); + const subListClasses = classNames({ + "mx_RoomSubList": true, + "mx_RoomSubList_hidden": len && isCollapsed, + "mx_RoomSubList_nonEmpty": len && !isCollapsed, + }); + + let content; + if (len) { if (isCollapsed) { - return
- {this._getHeaderJsx(isCollapsed)} -
; + // no body } else if (this._canUseLazyListRendering()) { - return
- {this._getHeaderJsx(isCollapsed)} - + content = ( + -
; + ); } else { const roomTiles = this.props.list.map(r => this.makeRoomTile(r)); const tiles = roomTiles.concat(this.props.extraTiles); - return
- {this._getHeaderJsx(isCollapsed)} - + content = ( + { tiles } -
; + ); } } else { - const Loader = sdk.getComponent("elements.Spinner"); - let content; if (this.props.showSpinner && !isCollapsed) { + const Loader = sdk.getComponent("elements.Spinner"); content = ; } - - return ( -
- { this._getHeaderJsx(isCollapsed) } - { content } -
- ); } + + return ( +
+ { this._getHeaderJsx(isCollapsed) } + { content } +
+ ); }, }); diff --git a/src/components/views/rooms/RoomList.js b/src/components/views/rooms/RoomList.js index 6c031563cd..d8092eae22 100644 --- a/src/components/views/rooms/RoomList.js +++ b/src/components/views/rooms/RoomList.js @@ -49,21 +49,6 @@ function labelForTagName(tagName) { return tagName; } -function phraseForSection(section) { - switch (section) { - case 'm.favourite': - return _t('Drop here to favourite'); - case 'im.vector.fake.direct': - return _t('Drop here to tag direct chat'); - case 'im.vector.fake.recent': - return _t('Drop here to restore'); - case 'm.lowpriority': - return _t('Drop here to demote'); - default: - return _t('Drop here to tag %(section)s', {section: section}); - } -} - module.exports = createReactClass({ displayName: 'RoomList', @@ -203,7 +188,7 @@ module.exports = createReactClass({ this.resizer.setClassNames({ handle: "mx_ResizeHandle", vertical: "mx_ResizeHandle_vertical", - reverse: "mx_ResizeHandle_reverse" + reverse: "mx_ResizeHandle_reverse", }); this._layout.update( this._layoutSections, @@ -584,23 +569,6 @@ module.exports = createReactClass({ } }, - _getHeaderItems: function(section) { - const StartChatButton = sdk.getComponent('elements.StartChatButton'); - const RoomDirectoryButton = sdk.getComponent('elements.RoomDirectoryButton'); - const CreateRoomButton = sdk.getComponent('elements.CreateRoomButton'); - switch (section) { - case 'im.vector.fake.direct': - return - - ; - case 'im.vector.fake.recent': - return - - - ; - } - }, - _makeGroupInviteTiles(filter) { const ret = []; const lcFilter = filter && filter.toLowerCase(); @@ -676,7 +644,7 @@ module.exports = createReactClass({ props = Object.assign({}, defaultProps, props); const isLast = i === subListsProps.length - 1; const len = props.list.length + (props.extraTiles ? props.extraTiles.length : 0); - const {key, label, onHeaderClick, ... otherProps} = props; + const {key, label, onHeaderClick, ...otherProps} = props; const chosenKey = key || label; const onSubListHeaderClick = (collapsed) => { this._handleCollapsedState(chosenKey, collapsed); @@ -746,16 +714,14 @@ module.exports = createReactClass({ list: this.state.lists['im.vector.fake.direct'], label: _t('People'), tagName: "im.vector.fake.direct", - headerItems: this._getHeaderItems('im.vector.fake.direct'), order: "recent", incomingCall: incomingCallIfTaggedAs('im.vector.fake.direct'), - onAddRoom: () => {dis.dispatch({action: 'view_create_chat'})}, + onAddRoom: () => {dis.dispatch({action: 'view_create_chat'});}, addRoomLabel: _t("Start chat"), }, { list: this.state.lists['im.vector.fake.recent'], label: _t('Rooms'), - headerItems: this._getHeaderItems('im.vector.fake.recent'), order: "recent", incomingCall: incomingCallIfTaggedAs('im.vector.fake.recent'), onAddRoom: () => {dis.dispatch({action: 'view_create_room'});},