Add option to unset room avatar
Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
parent
d7c3fc9adb
commit
e5c8e3e7ad
2 changed files with 32 additions and 2 deletions
|
@ -53,6 +53,10 @@ module.exports = React.createClass({
|
|||
};
|
||||
},
|
||||
|
||||
componentWillMount: function() {
|
||||
MatrixClientPeg.get().on("RoomState.events", this.onRoomStateEvents);
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(newProps) {
|
||||
if (this.avatarSet) {
|
||||
// don't clobber what the user has just set
|
||||
|
@ -63,6 +67,24 @@ module.exports = React.createClass({
|
|||
});
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
if (MatrixClientPeg.get()) {
|
||||
MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents);
|
||||
}
|
||||
},
|
||||
|
||||
onRoomStateEvents: function(ev) {
|
||||
if (ev.getRoomId() !== this.props.room.roomId || ev.getType() !== 'm.room.avatar'
|
||||
|| ev.getSender() !== MatrixClientPeg.get().getUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ev.getContent().url) {
|
||||
this.avatarSet = false;
|
||||
this.setState({}); // force update
|
||||
}
|
||||
},
|
||||
|
||||
setAvatarFromFile: function(file) {
|
||||
let newUrl = null;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue