Update room header when room state changes
Force an update so that we see the latest state. Fixes https://github.com/vector-im/vector-web/issues/1299
This commit is contained in:
parent
6422f7ecc8
commit
0d261c37c2
1 changed files with 21 additions and 0 deletions
|
@ -48,12 +48,33 @@ module.exports = React.createClass({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidMount: function() {
|
||||||
|
var cli = MatrixClientPeg.get();
|
||||||
|
cli.on("RoomState.events", this._onRoomStateEvents);
|
||||||
|
},
|
||||||
|
|
||||||
componentDidUpdate: function() {
|
componentDidUpdate: function() {
|
||||||
if (this.refs.topic) {
|
if (this.refs.topic) {
|
||||||
linkifyElement(this.refs.topic, linkifyMatrix.options);
|
linkifyElement(this.refs.topic, linkifyMatrix.options);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentWillUnmount: function() {
|
||||||
|
var cli = MatrixClientPeg.get();
|
||||||
|
if (cli) {
|
||||||
|
cli.removeListener("RoomState.events", this._onRoomStateEvents);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_onRoomStateEvents: function(event, state) {
|
||||||
|
if (!this.props.room || event.getRoomId() != this.props.room.roomId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// redisplay the room name, topic, etc.
|
||||||
|
this.forceUpdate();
|
||||||
|
},
|
||||||
|
|
||||||
onAvatarPickerClick: function(ev) {
|
onAvatarPickerClick: function(ev) {
|
||||||
if (this.refs.file_label) {
|
if (this.refs.file_label) {
|
||||||
this.refs.file_label.click();
|
this.refs.file_label.click();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue