Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Weblate 2017-10-14 21:13:35 +00:00
commit dde0cc1baa
4 changed files with 47 additions and 3 deletions

View File

@ -427,6 +427,11 @@ module.exports = React.createClass({
}); });
}, },
onAvatarRemoveClick: function() {
MatrixClientPeg.get().setAvatarUrl(null);
this.setState({avatarUrl: null}); // the avatar update will complete async for us
},
onLogoutClicked: function(ev) { onLogoutClicked: function(ev) {
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
Modal.createTrackedDialog('Logout E2E Export', '', QuestionDialog, { Modal.createTrackedDialog('Logout E2E Export', '', QuestionDialog, {
@ -1322,7 +1327,11 @@ module.exports = React.createClass({
</div> </div>
<div className="mx_UserSettings_avatarPicker"> <div className="mx_UserSettings_avatarPicker">
<div onClick={this.onAvatarPickerClick}> <div className="mx_UserSettings_avatarPicker_remove" onClick={this.onAvatarRemoveClick}>
<img src="img/cancel.svg" width="15" height="15"
alt={_t("Remove avatar")} title={_t("Remove avatar")} />
</div>
<div onClick={this.onAvatarPickerClick} className="mx_UserSettings_avatarPicker_imgContainer">
<ChangeAvatar ref="changeAvatar" initialAvatarUrl={avatarUrl} <ChangeAvatar ref="changeAvatar" initialAvatarUrl={avatarUrl}
showUploadSection={false} className="mx_UserSettings_avatarPicker_img" /> showUploadSection={false} className="mx_UserSettings_avatarPicker_img" />
</div> </div>

View File

@ -129,6 +129,10 @@ module.exports = React.createClass({
}).done(); }).done();
}, },
onAvatarRemoveClick: function() {
MatrixClientPeg.get().sendStateEvent(this.props.room.roomId, 'm.room.avatar', {url: null}, '');
},
onShowRhsClick: function(ev) { onShowRhsClick: function(ev) {
dis.dispatch({ action: 'show_right_panel' }); dis.dispatch({ action: 'show_right_panel' });
}, },
@ -273,6 +277,10 @@ module.exports = React.createClass({
</label> </label>
<input id="avatarInput" type="file" onChange={this.onAvatarSelected} /> <input id="avatarInput" type="file" onChange={this.onAvatarSelected} />
</div> </div>
<div className="mx_RoomHeader_avatarPicker_remove" onClick={this.onAvatarRemoveClick}>
<img src="img/cancel.svg" width="10"
alt={_t("Remove avatar")} title={_t("Remove avatar")} />
</div>
</div> </div>
); );
} else if (this.props.room || (this.props.oobData && this.props.oobData.name)) { } else if (this.props.room || (this.props.oobData && this.props.oobData.name)) {

View File

@ -53,6 +53,10 @@ module.exports = React.createClass({
}; };
}, },
componentWillMount: function() {
MatrixClientPeg.get().on("RoomState.events", this.onRoomStateEvents);
},
componentWillReceiveProps: function(newProps) { componentWillReceiveProps: function(newProps) {
if (this.avatarSet) { if (this.avatarSet) {
// don't clobber what the user has just set // don't clobber what the user has just set
@ -63,6 +67,28 @@ module.exports = React.createClass({
}); });
}, },
componentWillUnmount: function() {
if (MatrixClientPeg.get()) {
MatrixClientPeg.get().removeListener("RoomState.events", this.onRoomStateEvents);
}
},
onRoomStateEvents: function(ev) {
if (!this.props.room) {
return;
}
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) { setAvatarFromFile: function(file) {
let newUrl = null; let newUrl = null;

View File

@ -633,6 +633,7 @@
"quote": "quote", "quote": "quote",
"bullet": "bullet", "bullet": "bullet",
"numbullet": "numbullet", "numbullet": "numbullet",
"Remove avatar": "Remove avatar",
"%(severalUsers)sjoined %(repeats)s times": "%(severalUsers)sjoined %(repeats)s times", "%(severalUsers)sjoined %(repeats)s times": "%(severalUsers)sjoined %(repeats)s times",
"%(oneUser)sjoined %(repeats)s times": "%(oneUser)sjoined %(repeats)s times", "%(oneUser)sjoined %(repeats)s times": "%(oneUser)sjoined %(repeats)s times",
"%(severalUsers)sjoined": "%(severalUsers)sjoined", "%(severalUsers)sjoined": "%(severalUsers)sjoined",