File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,13 +34,24 @@ module.exports = {
3434 } ,
3535
3636 getInitialState : function ( ) {
37- this . urlList = this . getUrlList ( ) ;
38- this . urlListIndex = - 1 ;
37+ this . _update ( ) ;
3938 return {
4039 imageUrl : this . _nextUrl ( )
4140 } ;
4241 } ,
4342
43+ componentWillReceiveProps : function ( nextProps ) {
44+ this . _update ( ) ;
45+ this . setState ( {
46+ imageUrl : this . _nextUrl ( )
47+ } ) ;
48+ } ,
49+
50+ _update : function ( ) {
51+ this . urlList = this . getUrlList ( ) ;
52+ this . urlListIndex = - 1 ;
53+ } ,
54+
4455 _nextUrl : function ( ) {
4556 do {
4657 ++ this . urlListIndex ;
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ var MatrixClientPeg = require("../../MatrixClientPeg");
1919
2020module . exports = {
2121 propTypes : {
22- initialAvatarUrl : React . PropTypes . string . isRequired ,
22+ initialAvatarUrl : React . PropTypes . string ,
23+ room : React . PropTypes . object ,
2324 } ,
2425
2526 Phases : {
@@ -44,15 +45,24 @@ module.exports = {
4445 var self = this ;
4546 MatrixClientPeg . get ( ) . uploadContent ( file ) . then ( function ( url ) {
4647 newUrl = url ;
47- return MatrixClientPeg . get ( ) . setAvatarUrl ( url ) ;
48+ if ( self . props . room ) {
49+ return MatrixClientPeg . get ( ) . sendStateEvent (
50+ self . props . room . roomId ,
51+ 'm.room.avatar' ,
52+ { url : url } ,
53+ ''
54+ ) ;
55+ } else {
56+ return MatrixClientPeg . get ( ) . setAvatarUrl ( url ) ;
57+ }
4858 } ) . done ( function ( ) {
4959 self . setState ( {
5060 phase : self . Phases . Display ,
5161 avatarUrl : MatrixClientPeg . get ( ) . mxcUrlToHttp ( newUrl )
5262 } ) ;
5363 } , function ( error ) {
5464 self . setState ( {
55- phase : this . Phases . Error
65+ phase : self . Phases . Error
5666 } ) ;
5767 self . onError ( error ) ;
5868 } ) ;
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ module.exports = {
2828 cli . on ( "Room" , this . onRoom ) ;
2929 cli . on ( "Room.timeline" , this . onRoomTimeline ) ;
3030 cli . on ( "Room.name" , this . onRoomName ) ;
31+ cli . on ( "RoomState.events" , this . onRoomStateEvents ) ;
3132
3233 var rooms = this . getRoomList ( ) ;
3334 this . setState ( {
@@ -84,6 +85,10 @@ module.exports = {
8485 this . refreshRoomList ( ) ;
8586 } ,
8687
88+ onRoomStateEvents : function ( ev , state ) {
89+ this . refreshRoomList ( ) ;
90+ } ,
91+
8792 refreshRoomList : function ( ) {
8893 var rooms = this . getRoomList ( ) ;
8994 this . setState ( {
You can’t perform that action at this time.
0 commit comments