[FIX] Respect Use Real Name when sent an attachment

This commit is contained in:
Reinaldo Neto 2023-02-08 15:49:23 -03:00
parent c4a2ce20c6
commit 5fcfb8ea45
1 changed files with 10 additions and 2 deletions

View File

@ -24,8 +24,16 @@ const formatMsg = ({ lastMessage, type, showLastMessage, username, useRealName }
const isLastMessageSentByMe = lastMessage.u.username === username;
if (!lastMessage.msg && lastMessage.attachments && Object.keys(lastMessage.attachments).length) {
const user = isLastMessageSentByMe ? I18n.t('You') : lastMessage.u.username;
return I18n.t('User_sent_an_attachment', { user });
const userAttachment = () => {
if (isLastMessageSentByMe) {
return I18n.t('You');
}
if (useRealName && lastMessage.u.name) {
return lastMessage.u.name;
}
return lastMessage.u.username;
};
return I18n.t('User_sent_an_attachment', { user: userAttachment() });
}
// Encrypted message pending decrypt