From 28b42d512ad49359df2859e3cefa377fd42ec9ef Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 8 Aug 2019 20:07:38 +0100 Subject: [PATCH] Use the room name rather than sender name for fallback room avatar event Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/messages/RoomAvatarEvent.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/views/messages/RoomAvatarEvent.js b/src/components/views/messages/RoomAvatarEvent.js index d035fc9237..72d0d1926a 100644 --- a/src/components/views/messages/RoomAvatarEvent.js +++ b/src/components/views/messages/RoomAvatarEvent.js @@ -31,12 +31,21 @@ module.exports = React.createClass({ mxEvent: PropTypes.object.isRequired, }, - onAvatarClick: function(name) { - const httpUrl = MatrixClientPeg.get().mxcUrlToHttp(this.props.mxEvent.getContent().url); + onAvatarClick: function() { + const cli = MatrixClientPeg.get(); + const ev = this.props.mxEvent; + const httpUrl = cli.mxcUrlToHttp(ev.getContent().url); + + const room = cli.getRoom(this.props.mxEvent.getRoomId()); + const text = _t('%(senderDisplayName)s changed the avatar for %(roomName)s', { + senderDisplayName: ev.sender && ev.sender.name ? ev.sender.name : ev.getSender(), + roomName: room ? room.name : '', + }); + const ImageView = sdk.getComponent("elements.ImageView"); const params = { src: httpUrl, - name: name, + name: text, }; Modal.createDialog(ImageView, params, "mx_Dialog_lightbox"); }, @@ -47,15 +56,11 @@ module.exports = React.createClass({ const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); - const name = _t('%(senderDisplayName)s changed the avatar for %(roomName)s', { - senderDisplayName: senderDisplayName, - roomName: room ? room.name : '', - }); if (!ev.getContent().url || ev.getContent().url.trim().length === 0) { return (
- { _t('%(senderDisplayName)s removed the room avatar.', {senderDisplayName: senderDisplayName}) } + { _t('%(senderDisplayName)s removed the room avatar.', {senderDisplayName}) }
); } @@ -75,8 +80,8 @@ module.exports = React.createClass({ { 'img': () => - + onClick={this.onAvatarClick}> + , }) }