From 53014ce02265746b16acb227b1f982a0c17fbc92 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Fri, 26 Oct 2018 10:24:00 -0300 Subject: [PATCH] Check if lastMessage has an attachment and show "User sent an attachment" at RoomsList (#510) --- app/i18n/locales/en.js | 5 +++-- app/i18n/locales/pt-BR.js | 6 ++++-- app/presentation/RoomItem.js | 11 ++++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index 76ebecd21..9f67b428b 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -325,6 +325,7 @@ export default { User_is_no_longer_role_by_: '{{user}} is no longer {{role}} by {{userBy}}', User_muted_by: 'User {{userMuted}} muted by {{userBy}}', User_removed_by: 'User {{userRemoved}} removed by {{userBy}}', + User_sent_an_attachment: '{{user}} sent an attachment', User_unmuted_by: 'User {{userUnmuted}} unmuted by {{userBy}}', User_was_set_role_by_: '{{user}} was set {{role}} by {{userBy}}', Username_is_empty: 'Username is empty', @@ -343,7 +344,7 @@ export default { You_can_search_using_RegExp_eg: 'You can search using RegExp. e.g. `/^text$/i`', You_colon: 'You: ', you_were_mentioned: 'you were mentioned', - You_will_not_be_able_to_recover_this_message: 'You will not be able to recover this message!', you: 'you', - Your_server: 'Your server' + You: 'You', + You_will_not_be_able_to_recover_this_message: 'You will not be able to recover this message!' }; diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index 9b15e73d2..bce2d48ea 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -323,6 +323,7 @@ export default { User_is_no_longer_role_by_: '{{user}} não pertence mais à {{role}} por {{userBy}}', User_muted_by: 'User {{userMuted}} muted por {{userBy}}', User_removed_by: 'Usuário {{userRemoved}} removido por {{userBy}}', + User_sent_an_attachment: '{{user}} enviou um anexo', User_unmuted_by: '{{userBy}} permitiu que {{userUnmuted}} fale na sala', User_was_set_role_by_: '{{user}} foi definido como {{role}} por {{userBy}}', Username_is_empty: 'Usuário está vazio', @@ -340,6 +341,7 @@ export default { You_can_search_using_RegExp_eg: 'Você pode pesquisar usando expressões regulares, por exemplo `/^text$/i`', You_colon: 'Você: ', you_were_mentioned: 'você foi mencionado', - You_will_not_be_able_to_recover_this_message: 'Você não será capaz de recuperar essa mensagem!', - you: 'você' + you: 'você', + You: 'Você', + You_will_not_be_able_to_recover_this_message: 'Você não será capaz de recuperar essa mensagem!' }; diff --git a/app/presentation/RoomItem.js b/app/presentation/RoomItem.js index 26f91e056..3e39558fd 100644 --- a/app/presentation/RoomItem.js +++ b/app/presentation/RoomItem.js @@ -189,8 +189,17 @@ export default class RoomItem extends React.Component { } let prefix = ''; + const me = lastMessage.u.username === username; - if (lastMessage.u.username === username) { + if (!lastMessage.msg && Object.keys(lastMessage.attachments).length > 0) { + if (me) { + return I18n.t('User_sent_an_attachment', { user: I18n.t('You') }); + } else { + return I18n.t('User_sent_an_attachment', { user: lastMessage.u.username }); + } + } + + if (me) { prefix = I18n.t('You_colon'); } else if (type !== 'd') { prefix = `${ lastMessage.u.username }: `;