Skip to content

Commit 59f419b

Browse files
committed
Merge pull request element-hq#541 from vector-im/kegan/archived-rooms
Add more props to RoomSubList
2 parents d7b8774 + dcea0dd commit 59f419b

3 files changed

Lines changed: 37 additions & 14 deletions

File tree

‎src/components/structures/RoomSubList.js‎

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,34 @@ var RoomSubList = React.createClass({
6161
tagName: React.PropTypes.string,
6262
editable: React.PropTypes.bool,
6363
order: React.PropTypes.string.isRequired,
64-
bottommost: React.PropTypes.bool,
6564
selectedRoom: React.PropTypes.string.isRequired,
6665
activityMap: React.PropTypes.object.isRequired,
66+
startAsHidden: React.PropTypes.bool,
67+
showSpinner: React.PropTypes.bool, // true to show a spinner if 0 elements when expanded
68+
69+
// TODO: Fix the name of this. This is too easily confused with the
70+
// "hidden" state which is the expanded (or not) view of the list of rooms.
71+
// What this prop *really* does is control whether the room name is displayed
72+
// so it should be named as such.
6773
collapsed: React.PropTypes.bool.isRequired,
68-
incomingCall: React.PropTypes.object,
74+
onHeaderClick: React.PropTypes.func,
75+
alwaysShowHeader: React.PropTypes.bool,
76+
incomingCall: React.PropTypes.object
6977
},
7078

7179
getInitialState: function() {
7280
return {
73-
hidden: false,
81+
hidden: this.props.startAsHidden || false,
7482
sortedList: [],
7583
};
7684
},
7785

86+
getDefaultProps: function() {
87+
return {
88+
onHeaderClick: function() {} // NOP
89+
};
90+
},
91+
7892
componentWillMount: function() {
7993
this.sortList(this.props.list, this.props.order);
8094
},
@@ -86,7 +100,9 @@ var RoomSubList = React.createClass({
86100
},
87101

88102
onClick: function(ev) {
89-
this.setState({ hidden : !this.state.hidden });
103+
var isHidden = !this.state.hidden;
104+
this.setState({ hidden : isHidden });
105+
this.props.onHeaderClick(isHidden);
90106
},
91107

92108
tsOfNewestEvent: function(room) {
@@ -247,6 +263,17 @@ var RoomSubList = React.createClass({
247263
});
248264
},
249265

266+
_getHeaderJsx: function() {
267+
return (
268+
<h2 onClick={ this.onClick } className="mx_RoomSubList_label">
269+
{ this.props.collapsed ? '' : this.props.label }
270+
<img className="mx_RoomSubList_chevron"
271+
src={ this.state.hidden ? "img/list-open.svg" : "img/list-close.svg" }
272+
width="10" height="10" />
273+
</h2>
274+
);
275+
},
276+
250277
render: function() {
251278
var connectDropTarget = this.props.connectDropTarget;
252279
var RoomDropTarget = sdk.getComponent('rooms.RoomDropTarget');
@@ -262,8 +289,7 @@ var RoomSubList = React.createClass({
262289

263290
if (this.state.sortedList.length > 0 || this.props.editable) {
264291
var subList;
265-
var classes = "mx_RoomSubList" +
266-
(this.props.bottommost ? " mx_RoomSubList_bottommost" : "");
292+
var classes = "mx_RoomSubList";
267293

268294
if (!this.state.hidden) {
269295
subList = <div className={ classes }>
@@ -278,16 +304,17 @@ var RoomSubList = React.createClass({
278304

279305
return connectDropTarget(
280306
<div>
281-
<h2 onClick={ this.onClick } className="mx_RoomSubList_label">{ this.props.collapsed ? '' : this.props.label }
282-
<img className="mx_RoomSubList_chevron" src={ this.state.hidden ? "img/list-open.svg" : "img/list-close.svg" } width="10" height="10"/>
283-
</h2>
307+
{ this._getHeaderJsx() }
284308
{ subList }
285309
</div>
286310
);
287311
}
288312
else {
313+
var Loader = sdk.getComponent("elements.Spinner");
289314
return (
290315
<div className="mx_RoomSubList">
316+
{ this.props.alwaysShowHeader ? this._getHeaderJsx() : undefined }
317+
{ (this.props.showSpinner && !this.state.hidden) ? <Loader /> : undefined }
291318
</div>
292319
);
293320
}

‎src/skins/vector/css/organisms/RoomList.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
.mx_RoomList {
1818
padding-top: 24px;
1919
padding-bottom: 12px;
20+
min-height: 400px;
2021
}
2122

2223
.mx_RoomList_expandButton {

‎src/skins/vector/css/organisms/RoomSubList.css‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ limitations under the License.
2020
width: 100%;
2121
}
2222

23-
.mx_RoomSubList_bottommost {
24-
/* XXX: this should really be 100% of the RoomList height, but can't seem to get at it */
25-
min-height: 400px;
26-
}
27-
2823
.mx_RoomSubList_label {
2924
text-transform: uppercase;
3025
color: #3d3b39;

0 commit comments

Comments
 (0)