@@ -65,16 +65,12 @@ var RoomSubList = React.createClass({
6565 selectedRoom : React . PropTypes . string . isRequired ,
6666 startAsHidden : React . PropTypes . bool ,
6767 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 ,
68+ collapsed : React . PropTypes . bool . isRequired , // is LeftPanel collapsed?
7469 onHeaderClick : React . PropTypes . func ,
7570 alwaysShowHeader : React . PropTypes . bool ,
7671 incomingCall : React . PropTypes . object ,
77- onShowMoreRooms : React . PropTypes . func
72+ onShowMoreRooms : React . PropTypes . func ,
73+ searchFilter : React . PropTypes . string ,
7874 } ,
7975
8076 getInitialState : function ( ) {
@@ -93,13 +89,20 @@ var RoomSubList = React.createClass({
9389 } ,
9490
9591 componentWillMount : function ( ) {
96- this . sortList ( this . props . list , this . props . order ) ;
92+ this . sortList ( this . applySearchFilter ( this . props . list , this . props . searchFilter ) , this . props . order ) ;
9793 } ,
9894
9995 componentWillReceiveProps : function ( newProps ) {
10096 // order the room list appropriately before we re-render
10197 //if (debug) console.log("received new props, list = " + newProps.list);
102- this . sortList ( newProps . list , newProps . order ) ;
98+ this . sortList ( this . applySearchFilter ( newProps . list , newProps . searchFilter ) , newProps . order ) ;
99+ } ,
100+
101+ applySearchFilter : function ( list , filter ) {
102+ if ( filter === "" ) return list ;
103+ return list . filter ( ( room ) => {
104+ return room . name && room . name . toLowerCase ( ) . indexOf ( filter . toLowerCase ( ) ) >= 0
105+ } ) ;
103106 } ,
104107
105108 onClick : function ( ev ) {
@@ -278,7 +281,7 @@ var RoomSubList = React.createClass({
278281 return (
279282 < h2 onClick = { this . onClick } className = "mx_RoomSubList_label" >
280283 { this . props . collapsed ? '' : this . props . label }
281- < TintableSvg className = "mx_RoomSubList_chevron"
284+ < img className = "mx_RoomSubList_chevron"
282285 src = { this . state . hidden ? "img/list-close.svg" : "img/list-open.svg" }
283286 width = "10" height = "10" />
284287 </ h2 >
0 commit comments