@@ -121,43 +121,32 @@ export default class RoomProfileSettings extends React.Component<IProps, IState>
121
121
this . setState ( { profileFieldsTouched : { } } ) ;
122
122
123
123
const client = MatrixClientPeg . get ( ) ;
124
-
125
- let originalDisplayName : string ;
126
- let avatarUrl : string ;
127
- let originalAvatarUrl : string ;
128
- let originalTopic : string ;
129
- let avatarFile : File ;
124
+ const newState : Partial < IState > = { } ;
130
125
131
126
// TODO: What do we do about errors?
132
127
const displayName = this . state . displayName . trim ( ) ;
133
128
if ( this . state . originalDisplayName !== this . state . displayName ) {
134
129
await client . setRoomName ( this . props . roomId , displayName ) ;
135
- originalDisplayName = displayName ;
130
+ newState . originalDisplayName = displayName ;
131
+ newState . displayName = displayName ;
136
132
}
137
133
138
134
if ( this . state . avatarFile ) {
139
135
const uri = await client . uploadContent ( this . state . avatarFile ) ;
140
136
await client . sendStateEvent ( this . props . roomId , 'm.room.avatar' , { url : uri } , '' ) ;
141
- avatarUrl = mediaFromMxc ( uri ) . getSquareThumbnailHttp ( 96 ) ;
142
- originalAvatarUrl = avatarUrl ;
143
- avatarFile = null ;
137
+ newState . avatarUrl = mediaFromMxc ( uri ) . getSquareThumbnailHttp ( 96 ) ;
138
+ newState . originalAvatarUrl = newState . avatarUrl ;
139
+ newState . avatarFile = null ;
144
140
} else if ( this . state . originalAvatarUrl !== this . state . avatarUrl ) {
145
141
await client . sendStateEvent ( this . props . roomId , 'm.room.avatar' , { } , '' ) ;
146
142
}
147
143
148
144
if ( this . state . originalTopic !== this . state . topic ) {
149
145
await client . setRoomTopic ( this . props . roomId , this . state . topic ) ;
150
- originalTopic = this . state . topic ;
146
+ newState . originalTopic = this . state . topic ;
151
147
}
152
148
153
- this . setState ( {
154
- originalAvatarUrl,
155
- avatarUrl,
156
- originalDisplayName,
157
- originalTopic,
158
- displayName,
159
- avatarFile,
160
- } ) ;
149
+ this . setState ( newState as IState ) ;
161
150
} ;
162
151
163
152
private onDisplayNameChanged = ( e : React . ChangeEvent < HTMLInputElement > ) : void => {
0 commit comments