From 7ffb542cb59c95fe5ec72236916d3a7b746dcbc7 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 16 Nov 2017 15:24:36 +0000 Subject: [PATCH] Do something more sensible for sender profile name/aux opacity - If no translation is needed, don't do it. - For now, ignore the fact that this doens't allow us easily to put Flair into "luke sent an image" but we don't kow where the flair should go for this anyway. --- .../views/messages/SenderProfile.js | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/src/components/views/messages/SenderProfile.js b/src/components/views/messages/SenderProfile.js index 10e3082938..28064070cb 100644 --- a/src/components/views/messages/SenderProfile.js +++ b/src/components/views/messages/SenderProfile.js @@ -19,7 +19,7 @@ import React from 'react'; import sdk from '../../../index'; import Flair from '../elements/Flair.js'; -import { _t, substitute } from '../../../languageHandler'; +import { _t } from '../../../languageHandler'; export default function SenderProfile(props) { const EmojiText = sdk.getComponent('elements.EmojiText'); @@ -31,39 +31,30 @@ export default function SenderProfile(props) { return ; // emote message must include the name so don't duplicate it } + const nameElem = { name || '' }; + // Name + flair - const nameElem = [ - { name || '' }, - props.enableFlair ? + const nameFlair = + + { nameElem } + + { props.enableFlair ? - : null, - ]; + : null + } + ; - let content; - if (props.text) { - content = _t(props.text, { senderName: () => nameElem }); - } else { - // There is nothing to translate here, so call substitute() instead - content = substitute('%(senderName)s', { senderName: () => nameElem }); - } + const content = props.text ? + + { _t(props.text, { senderName: () => nameElem }) } + : nameFlair; - // The text surrounding the user name must be wrapped in order for it to have the correct opacity. - // It is not possible to wrap the whole thing, because the user name might contain flair which should - // be shown at full opacity. Sadly CSS does not make it possible to "reset" opacity so we have to do it - // in parts like this. Sometimes CSS makes me a sad panda :-( - // XXX: This could be avoided if the actual colour is set, rather than faking it with opacity return (
- { content.props.children[0] ? - { content.props.children[0] } : '' - } - { content.props.children[1] } - { content.props.children[2] ? - { content.props.children[2] } : '' - } + { content }
); }