@@ -64,7 +64,9 @@ var RoomSubList = React.createClass({
6464 bottommost : React . PropTypes . bool ,
6565 selectedRoom : React . PropTypes . string . isRequired ,
6666 activityMap : React . PropTypes . object . isRequired ,
67- collapsed : React . PropTypes . bool . isRequired
67+ collapsed : React . PropTypes . bool . isRequired ,
68+ onHeaderClick : React . PropTypes . func ,
69+ alwaysShowHeader : React . PropTypes . bool
6870 } ,
6971
7072 getInitialState : function ( ) {
@@ -74,6 +76,12 @@ var RoomSubList = React.createClass({
7476 } ;
7577 } ,
7678
79+ getDefaultProps : function ( ) {
80+ return {
81+ onHeaderClick : function ( ) { } // NOP
82+ } ;
83+ } ,
84+
7785 componentWillMount : function ( ) {
7886 this . sortList ( this . props . list , this . props . order ) ;
7987 } ,
@@ -85,7 +93,9 @@ var RoomSubList = React.createClass({
8593 } ,
8694
8795 onClick : function ( ev ) {
88- this . setState ( { hidden : ! this . state . hidden } ) ;
96+ var isHidden = ! this . state . hidden ;
97+ this . setState ( { hidden : isHidden } ) ;
98+ this . props . onHeaderClick ( isHidden ) ;
8999 } ,
90100
91101 tsOfNewestEvent : function ( room ) {
@@ -244,6 +254,17 @@ var RoomSubList = React.createClass({
244254 } ) ;
245255 } ,
246256
257+ _getHeaderJsx : function ( ) {
258+ return (
259+ < h2 onClick = { this . onClick } className = "mx_RoomSubList_label" >
260+ { this . props . collapsed ? '' : this . props . label }
261+ < img className = "mx_RoomSubList_chevron"
262+ src = { this . state . hidden ? "img/list-open.svg" : "img/list-close.svg" }
263+ width = "10" height = "10" />
264+ </ h2 >
265+ ) ;
266+ } ,
267+
247268 render : function ( ) {
248269 var connectDropTarget = this . props . connectDropTarget ;
249270 var RoomDropTarget = sdk . getComponent ( 'rooms.RoomDropTarget' ) ;
@@ -275,16 +296,15 @@ var RoomSubList = React.createClass({
275296
276297 return connectDropTarget (
277298 < div >
278- < h2 onClick = { this . onClick } className = "mx_RoomSubList_label" > { this . props . collapsed ? '' : this . props . label }
279- < img className = "mx_RoomSubList_chevron" src = { this . state . hidden ? "img/list-open.svg" : "img/list-close.svg" } width = "10" height = "10" />
280- </ h2 >
299+ { this . _getHeaderJsx ( ) }
281300 { subList }
282301 </ div >
283302 ) ;
284303 }
285304 else {
286305 return (
287306 < div className = "mx_RoomSubList" >
307+ { this . props . alwaysShowHeader ? this . _getHeaderJsx ( ) : undefined }
288308 </ div >
289309 ) ;
290310 }
0 commit comments