Skip to content

Commit 6a76d8a

Browse files
committed
Update room header when room name changes
1 parent 8fe6411 commit 6a76d8a

4 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎skins/base/views/molecules/RoomHeader.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = React.createClass({
5959
</div>
6060
<div className="mx_RoomHeader_info">
6161
<div className="mx_RoomHeader_name">
62-
<EditableText initalValue={this.props.room.name} onValueChanged={this.onNameChange} />
62+
<EditableText initialValue={this.props.room.name} onValueChanged={this.onNameChange} />
6363
</div>
6464
{ topic }
6565
</div>

‎skins/base/views/organisms/UserSettings.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module.exports = React.createClass({
6464
</div>
6565

6666
<div className="mx_UserSettings_DisplayName">
67-
<EditableText ref="displayname" initalValue={this.state.displayName} placeHolder="Click to set display name." onValueChanged={this.changeDisplayname}/>
67+
<EditableText ref="displayname" initialValue={this.state.displayName} placeHolder="Click to set display name." onValueChanged={this.changeDisplayname}/>
6868
<div className="mx_UserSettings_DisplayName_Edit" onClick={this.editDisplayName}>Edit</div>
6969
</div>
7070

‎src/controllers/atoms/EditableText.js‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var React = require('react');
2121
module.exports = {
2222
propTypes: {
2323
onValueChanged: React.PropTypes.func,
24-
initalValue: React.PropTypes.string,
24+
initialValue: React.PropTypes.string,
2525
placeHolder: React.PropTypes.string,
2626
},
2727

@@ -33,18 +33,24 @@ module.exports = {
3333
getDefaultProps: function() {
3434
return {
3535
onValueChanged: function() {},
36-
initalValue: '',
36+
initialValue: '',
3737
placeHolder: 'Click to set',
3838
};
3939
},
4040

4141
getInitialState: function() {
4242
return {
43-
value: this.props.initalValue,
43+
value: this.props.initialValue,
4444
phase: this.Phases.Display,
4545
}
4646
},
4747

48+
componentWillReceiveProps: function(nextProps) {
49+
this.setState({
50+
value: nextProps.initialValue
51+
});
52+
},
53+
4854
getValue: function() {
4955
return this.state.value;
5056
},

‎src/controllers/organisms/RoomView.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module.exports = {
4949
componentWillMount: function() {
5050
this.dispatcherRef = dis.register(this.onAction);
5151
MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline);
52+
MatrixClientPeg.get().on("Room.name", this.onRoomName);
5253
this.atBottom = true;
5354
},
5455

@@ -60,6 +61,7 @@ module.exports = {
6061
dis.unregister(this.dispatcherRef);
6162
if (MatrixClientPeg.get()) {
6263
MatrixClientPeg.get().removeListener("Room.timeline", this.onRoomTimeline);
64+
MatrixClientPeg.get().removeListener("Room.name", this.onRoomName);
6365
}
6466
},
6567

@@ -106,6 +108,14 @@ module.exports = {
106108
}
107109
},
108110

111+
onRoomName: function(room) {
112+
if (room.roomId == this.props.roomId) {
113+
this.setState({
114+
room: room
115+
});
116+
}
117+
},
118+
109119
componentDidMount: function() {
110120
if (this.refs.messageWrapper) {
111121
var messageWrapper = this.refs.messageWrapper.getDOMNode();

0 commit comments

Comments
 (0)