allow RoomSubList to use old behaviour of not hiding even if empty

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2018-06-30 17:06:33 +01:00
parent 41dee71d38
commit ca83f1e8c8
No known key found for this signature in database
GPG Key ID: 3F879DA5AD802A5E
1 changed files with 39 additions and 24 deletions

View File

@ -27,6 +27,7 @@ import * as RoomNotifs from '../../RoomNotifs';
import * as FormattingUtils from '../../utils/FormattingUtils'; import * as FormattingUtils from '../../utils/FormattingUtils';
import { KeyCode } from '../../Keyboard'; import { KeyCode } from '../../Keyboard';
import { Group } from 'matrix-js-sdk'; import { Group } from 'matrix-js-sdk';
import PropTypes from 'prop-types';
// turn this on for drop & drag console debugging galore // turn this on for drop & drag console debugging galore
@ -40,27 +41,28 @@ const RoomSubList = React.createClass({
debug: debug, debug: debug,
propTypes: { propTypes: {
list: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, list: PropTypes.arrayOf(PropTypes.object).isRequired,
label: React.PropTypes.string.isRequired, label: PropTypes.string.isRequired,
tagName: React.PropTypes.string, tagName: PropTypes.string,
editable: React.PropTypes.bool, editable: PropTypes.bool,
order: React.PropTypes.string.isRequired, order: PropTypes.string.isRequired,
// passed through to RoomTile and used to highlight room with `!` regardless of notifications count // passed through to RoomTile and used to highlight room with `!` regardless of notifications count
isInvite: React.PropTypes.bool, isInvite: PropTypes.bool,
startAsHidden: React.PropTypes.bool, startAsHidden: PropTypes.bool,
showSpinner: React.PropTypes.bool, // true to show a spinner if 0 elements when expanded showSpinner: PropTypes.bool, // true to show a spinner if 0 elements when expanded
collapsed: React.PropTypes.bool.isRequired, // is LeftPanel collapsed? collapsed: PropTypes.bool.isRequired, // is LeftPanel collapsed?
onHeaderClick: React.PropTypes.func, onHeaderClick: PropTypes.func,
alwaysShowHeader: React.PropTypes.bool, alwaysShowHeader: PropTypes.bool,
incomingCall: React.PropTypes.object, incomingCall: PropTypes.object,
onShowMoreRooms: React.PropTypes.func, onShowMoreRooms: PropTypes.func,
searchFilter: React.PropTypes.string, searchFilter: PropTypes.string,
emptyContent: React.PropTypes.node, // content shown if the list is empty emptyContent: PropTypes.node, // content shown if the list is empty
headerItems: React.PropTypes.node, // content shown in the sublist header headerItems: PropTypes.node, // content shown in the sublist header
extraTiles: React.PropTypes.arrayOf(React.PropTypes.node), // extra elements added beneath tiles extraTiles: PropTypes.arrayOf(PropTypes.node), // extra elements added beneath tiles
showEmpty: PropTypes.bool,
}, },
getInitialState: function() { getInitialState: function() {
@ -79,6 +81,7 @@ const RoomSubList = React.createClass({
}, // NOP }, // NOP
extraTiles: [], extraTiles: [],
isInvite: false, isInvite: false,
showEmpty: true,
}; };
}, },
@ -392,17 +395,29 @@ const RoomSubList = React.createClass({
const TruncatedList = sdk.getComponent('elements.TruncatedList'); const TruncatedList = sdk.getComponent('elements.TruncatedList');
let content; let content;
if (this.state.sortedList.length === 0 && this.props.extraTiles.length === 0) {
// if no search filter is applied and there is a placeholder defined then show it, otherwise show nothing if (this.props.showEmpty) {
if (!this.props.searchFilter && this.props.emptyContent) { // this is new behaviour with still controversial UX in that in hiding RoomSubLists the drop zones for DnD
// are also gone so when filtering users can't DnD rooms to some tags but is a lot cleaner otherwise.
if (this.state.sortedList.length === 0 && !this.props.searchFilter && this.props.extraTiles.length === 0) {
content = this.props.emptyContent; content = this.props.emptyContent;
} else { } else {
// don't show an empty sublist content = this.makeRoomTiles();
return null; content.push(...this.props.extraTiles);
} }
} else { } else {
content = this.makeRoomTiles(); if (this.state.sortedList.length === 0 && this.props.extraTiles.length === 0) {
content.push(...this.props.extraTiles); // if no search filter is applied and there is a placeholder defined then show it, otherwise show nothing
if (!this.props.searchFilter && this.props.emptyContent) {
content = this.props.emptyContent;
} else {
// don't show an empty sublist
return null;
}
} else {
content = this.makeRoomTiles();
content.push(...this.props.extraTiles);
}
} }
if (this.state.sortedList.length > 0 || this.props.extraTiles.length > 0 || this.props.editable) { if (this.state.sortedList.length > 0 || this.props.extraTiles.length > 0 || this.props.editable) {