twemojify names in reaction tooltip

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-01-24 14:54:53 +05:30
parent 4ef29ae26f
commit 0a0b45fb8e

View file

@ -298,19 +298,17 @@ function pickEmoji(e, roomId, eventId, roomTimeline) {
}
function genReactionMsg(userIds, reaction) {
const genLessContText = (text) => <span style={{ opacity: '.6' }}>{text}</span>;
let msg = <></>;
userIds.forEach((userId, index) => {
if (index === 0) msg = <>{getUsername(userId)}</>;
// eslint-disable-next-line react/jsx-one-expression-per-line
else if (index === userIds.length - 1) msg = <>{msg}{genLessContText(' and ')}{getUsername(userId)}</>;
// eslint-disable-next-line react/jsx-one-expression-per-line
else msg = <>{msg}{genLessContText(', ')}{getUsername(userId)}</>;
});
return (
<>
{msg}
{genLessContText(' reacted with')}
{userIds.map((userId, index) => (
<>
{twemojify(getUsername(userId))}
<span style={{ opacity: '.6' }}>
{index === userIds.length - 1 ? ' and ' : ', '}
</span>
</>
))}
<span style={{ opacity: '.6' }}>{' reacted with '}</span>
{twemojify(reaction, { className: 'react-emoji' })}
</>
);