mirror of https://github.com/vector-im/riot-web
Clean up RoomSubList from stale unused code paths
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
385e83fdbc
commit
2de88449aa
|
@ -57,8 +57,8 @@ const RoomSubList = createReactClass({
|
||||||
onHeaderClick: PropTypes.func,
|
onHeaderClick: PropTypes.func,
|
||||||
incomingCall: PropTypes.object,
|
incomingCall: PropTypes.object,
|
||||||
isFiltered: PropTypes.bool,
|
isFiltered: PropTypes.bool,
|
||||||
headerItems: PropTypes.node, // content shown in the sublist header
|
|
||||||
extraTiles: PropTypes.arrayOf(PropTypes.node), // extra elements added beneath tiles
|
extraTiles: PropTypes.arrayOf(PropTypes.node), // extra elements added beneath tiles
|
||||||
|
forceExpand: PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -299,21 +299,20 @@ const RoomSubList = createReactClass({
|
||||||
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;
|
||||||
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) {
|
if (isCollapsed) {
|
||||||
return <div ref="subList" className={subListClasses} role="group" aria-label={this.props.label}>
|
// no body
|
||||||
{this._getHeaderJsx(isCollapsed)}
|
|
||||||
</div>;
|
|
||||||
} else if (this._canUseLazyListRendering()) {
|
} else if (this._canUseLazyListRendering()) {
|
||||||
return <div ref="subList" className={subListClasses} role="group" aria-label={this.props.label}>
|
content = (
|
||||||
{this._getHeaderJsx(isCollapsed)}
|
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={this._onScroll}>
|
||||||
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
|
||||||
<LazyRenderList
|
<LazyRenderList
|
||||||
scrollTop={this.state.scrollTop }
|
scrollTop={this.state.scrollTop }
|
||||||
height={ this.state.scrollerHeight }
|
height={ this.state.scrollerHeight }
|
||||||
|
@ -321,31 +320,35 @@ const RoomSubList = createReactClass({
|
||||||
itemHeight={34}
|
itemHeight={34}
|
||||||
items={ this.props.list } />
|
items={ this.props.list } />
|
||||||
</IndicatorScrollbar>
|
</IndicatorScrollbar>
|
||||||
</div>;
|
);
|
||||||
} else {
|
} else {
|
||||||
const roomTiles = this.props.list.map(r => this.makeRoomTile(r));
|
const roomTiles = this.props.list.map(r => this.makeRoomTile(r));
|
||||||
const tiles = roomTiles.concat(this.props.extraTiles);
|
const tiles = roomTiles.concat(this.props.extraTiles);
|
||||||
return <div ref="subList" className={subListClasses} role="group" aria-label={this.props.label}>
|
content = (
|
||||||
{this._getHeaderJsx(isCollapsed)}
|
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={this._onScroll}>
|
||||||
<IndicatorScrollbar ref="scroller" className="mx_RoomSubList_scroll" onScroll={ this._onScroll }>
|
|
||||||
{ tiles }
|
{ tiles }
|
||||||
</IndicatorScrollbar>
|
</IndicatorScrollbar>
|
||||||
</div>;
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const Loader = sdk.getComponent("elements.Spinner");
|
|
||||||
let content;
|
|
||||||
if (this.props.showSpinner && !isCollapsed) {
|
if (this.props.showSpinner && !isCollapsed) {
|
||||||
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
content = <Loader />;
|
content = <Loader />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
|
||||||
<div ref="subList" className="mx_RoomSubList" role="group" aria-label={this.props.label}>
|
|
||||||
{ this._getHeaderJsx(isCollapsed) }
|
|
||||||
{ content }
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref="subList"
|
||||||
|
className={subListClasses}
|
||||||
|
role="group"
|
||||||
|
aria-label={this.props.label}
|
||||||
|
aria-expanded={!isCollapsed}
|
||||||
|
>
|
||||||
|
{ this._getHeaderJsx(isCollapsed) }
|
||||||
|
{ content }
|
||||||
|
</div>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -49,21 +49,6 @@ function labelForTagName(tagName) {
|
||||||
return 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({
|
module.exports = createReactClass({
|
||||||
displayName: 'RoomList',
|
displayName: 'RoomList',
|
||||||
|
|
||||||
|
@ -203,7 +188,7 @@ module.exports = createReactClass({
|
||||||
this.resizer.setClassNames({
|
this.resizer.setClassNames({
|
||||||
handle: "mx_ResizeHandle",
|
handle: "mx_ResizeHandle",
|
||||||
vertical: "mx_ResizeHandle_vertical",
|
vertical: "mx_ResizeHandle_vertical",
|
||||||
reverse: "mx_ResizeHandle_reverse"
|
reverse: "mx_ResizeHandle_reverse",
|
||||||
});
|
});
|
||||||
this._layout.update(
|
this._layout.update(
|
||||||
this._layoutSections,
|
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 <span className="mx_RoomList_headerButtons">
|
|
||||||
<StartChatButton size="16" />
|
|
||||||
</span>;
|
|
||||||
case 'im.vector.fake.recent':
|
|
||||||
return <span className="mx_RoomList_headerButtons">
|
|
||||||
<RoomDirectoryButton size="16" />
|
|
||||||
<CreateRoomButton size="16" />
|
|
||||||
</span>;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_makeGroupInviteTiles(filter) {
|
_makeGroupInviteTiles(filter) {
|
||||||
const ret = [];
|
const ret = [];
|
||||||
const lcFilter = filter && filter.toLowerCase();
|
const lcFilter = filter && filter.toLowerCase();
|
||||||
|
@ -676,7 +644,7 @@ module.exports = createReactClass({
|
||||||
props = Object.assign({}, defaultProps, props);
|
props = Object.assign({}, defaultProps, props);
|
||||||
const isLast = i === subListsProps.length - 1;
|
const isLast = i === subListsProps.length - 1;
|
||||||
const len = props.list.length + (props.extraTiles ? props.extraTiles.length : 0);
|
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 chosenKey = key || label;
|
||||||
const onSubListHeaderClick = (collapsed) => {
|
const onSubListHeaderClick = (collapsed) => {
|
||||||
this._handleCollapsedState(chosenKey, collapsed);
|
this._handleCollapsedState(chosenKey, collapsed);
|
||||||
|
@ -746,16 +714,14 @@ module.exports = createReactClass({
|
||||||
list: this.state.lists['im.vector.fake.direct'],
|
list: this.state.lists['im.vector.fake.direct'],
|
||||||
label: _t('People'),
|
label: _t('People'),
|
||||||
tagName: "im.vector.fake.direct",
|
tagName: "im.vector.fake.direct",
|
||||||
headerItems: this._getHeaderItems('im.vector.fake.direct'),
|
|
||||||
order: "recent",
|
order: "recent",
|
||||||
incomingCall: incomingCallIfTaggedAs('im.vector.fake.direct'),
|
incomingCall: incomingCallIfTaggedAs('im.vector.fake.direct'),
|
||||||
onAddRoom: () => {dis.dispatch({action: 'view_create_chat'})},
|
onAddRoom: () => {dis.dispatch({action: 'view_create_chat'});},
|
||||||
addRoomLabel: _t("Start chat"),
|
addRoomLabel: _t("Start chat"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
list: this.state.lists['im.vector.fake.recent'],
|
list: this.state.lists['im.vector.fake.recent'],
|
||||||
label: _t('Rooms'),
|
label: _t('Rooms'),
|
||||||
headerItems: this._getHeaderItems('im.vector.fake.recent'),
|
|
||||||
order: "recent",
|
order: "recent",
|
||||||
incomingCall: incomingCallIfTaggedAs('im.vector.fake.recent'),
|
incomingCall: incomingCallIfTaggedAs('im.vector.fake.recent'),
|
||||||
onAddRoom: () => {dis.dispatch({action: 'view_create_room'});},
|
onAddRoom: () => {dis.dispatch({action: 'view_create_room'});},
|
||||||
|
|
Loading…
Reference in New Issue