parent
8083dccfa5
commit
468a05c6f1
|
@ -27,30 +27,29 @@ export default function SenderProfile(props) {
|
||||||
const name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender();
|
const name = mxEvent.sender ? mxEvent.sender.name : mxEvent.getSender();
|
||||||
const {msgtype} = mxEvent.getContent();
|
const {msgtype} = mxEvent.getContent();
|
||||||
|
|
||||||
// Display sender name by default if nothing else is given
|
|
||||||
const text = props.text ? props.text : '%(senderName)s';
|
|
||||||
|
|
||||||
if (msgtype === 'm.emote') {
|
if (msgtype === 'm.emote') {
|
||||||
return <span />; // emote message must include the name so don't duplicate it
|
return <span />; // emote message must include the name so don't duplicate it
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name + flair
|
// Name + flair
|
||||||
const nameElem = [
|
const nameElem = [
|
||||||
<EmojiText className="mx_SenderProfile_name">{ name || '' }</EmojiText>,
|
<EmojiText key='name' className="mx_SenderProfile_name">{ name || '' }</EmojiText>,
|
||||||
props.enableFlair ?
|
props.enableFlair ?
|
||||||
<Flair
|
<Flair key='flair'
|
||||||
userId={mxEvent.getSender()}
|
userId={mxEvent.getSender()}
|
||||||
roomId={mxEvent.getRoomId()}
|
roomId={mxEvent.getRoomId()}
|
||||||
showRelated={true} />
|
showRelated={true} />
|
||||||
: null,
|
: null,
|
||||||
]
|
];
|
||||||
|
|
||||||
|
let content = '';
|
||||||
|
|
||||||
if(props.text) {
|
if(props.text) {
|
||||||
// Replace senderName, and wrap surrounding text in spans with the right class
|
// Replace senderName, and wrap surrounding text in spans with the right class
|
||||||
content = _tJsx(props.text, /^(.*)\%\(senderName\)s(.*)$/m, (p1, p2) => [
|
content = _tJsx(props.text, /^(.*)\%\(senderName\)s(.*)$/m, (p1, p2) => [
|
||||||
p1 ? <span className='mx_SenderProfile_aux'>{p1}</span> : null,
|
p1 ? <span className='mx_SenderProfile_aux'>{ p1 }</span> : null,
|
||||||
nameElem,
|
nameElem,
|
||||||
p2 ? <span className='mx_SenderProfile_aux'>{p2}</span> : null,
|
p2 ? <span className='mx_SenderProfile_aux'>{ p2 }</span> : null,
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
content = nameElem;
|
content = nameElem;
|
||||||
|
|
Loading…
Reference in New Issue