@@ -61,19 +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 ,
67- collapsed : React . PropTypes . bool . 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.
73+ collapsed : React . PropTypes . bool . isRequired ,
74+ onHeaderClick : React . PropTypes . func ,
75+ alwaysShowHeader : React . PropTypes . bool ,
76+ incomingCall : React . PropTypes . object
6877 } ,
6978
7079 getInitialState : function ( ) {
7180 return {
72- hidden : false ,
81+ hidden : this . props . startAsHidden || false ,
7382 sortedList : [ ] ,
7483 } ;
7584 } ,
7685
86+ getDefaultProps : function ( ) {
87+ return {
88+ onHeaderClick : function ( ) { } // NOP
89+ } ;
90+ } ,
91+
7792 componentWillMount : function ( ) {
7893 this . sortList ( this . props . list , this . props . order ) ;
7994 } ,
@@ -85,7 +100,9 @@ var RoomSubList = React.createClass({
85100 } ,
86101
87102 onClick : function ( ev ) {
88- this . setState ( { hidden : ! this . state . hidden } ) ;
103+ var isHidden = ! this . state . hidden ;
104+ this . setState ( { hidden : isHidden } ) ;
105+ this . props . onHeaderClick ( isHidden ) ;
89106 } ,
90107
91108 tsOfNewestEvent : function ( room ) {
@@ -239,11 +256,24 @@ var RoomSubList = React.createClass({
239256 selected = { selected }
240257 unread = { self . props . activityMap [ room . roomId ] === 1 }
241258 highlight = { self . props . activityMap [ room . roomId ] === 2 }
242- isInvite = { self . props . label === 'Invites' } />
259+ isInvite = { self . props . label === 'Invites' }
260+ incomingCall = { self . props . incomingCall && ( self . props . incomingCall . roomId === room . roomId ) ? self . props . incomingCall : null }
261+ />
243262 ) ;
244263 } ) ;
245264 } ,
246265
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-close.svg" : "img/list-open.svg" }
272+ width = "10" height = "10" />
273+ </ h2 >
274+ ) ;
275+ } ,
276+
247277 render : function ( ) {
248278 var connectDropTarget = this . props . connectDropTarget ;
249279 var RoomDropTarget = sdk . getComponent ( 'rooms.RoomDropTarget' ) ;
@@ -259,8 +289,7 @@ var RoomSubList = React.createClass({
259289
260290 if ( this . state . sortedList . length > 0 || this . props . editable ) {
261291 var subList ;
262- var classes = "mx_RoomSubList" +
263- ( this . props . bottommost ? " mx_RoomSubList_bottommost" : "" ) ;
292+ var classes = "mx_RoomSubList" ;
264293
265294 if ( ! this . state . hidden ) {
266295 subList = < div className = { classes } >
@@ -275,16 +304,17 @@ var RoomSubList = React.createClass({
275304
276305 return connectDropTarget (
277306 < 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 >
307+ { this . _getHeaderJsx ( ) }
281308 { subList }
282309 </ div >
283310 ) ;
284311 }
285312 else {
313+ var Loader = sdk . getComponent ( "elements.Spinner" ) ;
286314 return (
287315 < div className = "mx_RoomSubList" >
316+ { this . props . alwaysShowHeader ? this . _getHeaderJsx ( ) : undefined }
317+ { ( this . props . showSpinner && ! this . state . hidden ) ? < Loader /> : undefined }
288318 </ div >
289319 ) ;
290320 }
0 commit comments