@@ -53,6 +53,13 @@ module.exports = React.createClass({
5353 componentDidMount : function ( ) {
5454 var cli = MatrixClientPeg . get ( ) ;
5555 cli . on ( "RoomState.events" , this . _onRoomStateEvents ) ;
56+
57+ // When a room name occurs, RoomState.events is fired *before*
58+ // room.name is updated. So we have to listen to Room.name as well as
59+ // RoomState.events.
60+ if ( this . props . room ) {
61+ this . props . room . on ( "Room.name" , this . _onRoomNameChange ) ;
62+ }
5663 } ,
5764
5865 componentDidUpdate : function ( ) {
@@ -62,6 +69,9 @@ module.exports = React.createClass({
6269 } ,
6370
6471 componentWillUnmount : function ( ) {
72+ if ( this . props . room ) {
73+ this . props . room . removeListener ( "Room.name" , this . _onRoomNameChange ) ;
74+ }
6575 var cli = MatrixClientPeg . get ( ) ;
6676 if ( cli ) {
6777 cli . removeListener ( "RoomState.events" , this . _onRoomStateEvents ) ;
@@ -77,6 +87,10 @@ module.exports = React.createClass({
7787 this . forceUpdate ( ) ;
7888 } ,
7989
90+ _onRoomNameChange : function ( room ) {
91+ this . forceUpdate ( ) ;
92+ } ,
93+
8094 onAvatarPickerClick : function ( ev ) {
8195 if ( this . refs . file_label ) {
8296 this . refs . file_label . click ( ) ;
@@ -98,7 +112,7 @@ module.exports = React.createClass({
98112 description : "Failed to set avatar. " + errMsg
99113 } ) ;
100114 } ) . done ( ) ;
101- } ,
115+ } ,
102116
103117 /**
104118 * After editing the settings, get the new name for the room
@@ -272,7 +286,7 @@ module.exports = React.createClass({
272286
273287 var right_row ;
274288 if ( ! this . props . editing ) {
275- right_row =
289+ right_row =
276290 < div className = "mx_RoomHeader_rightRow" >
277291 { forget_button }
278292 { leave_button }
0 commit comments