Merge pull request #15714 from ramonlsouza/port-15687-25

fix: multiple answer translation in live results (2.5)
This commit is contained in:
Ramón Souza 2022-09-21 16:49:24 -03:00 committed by GitHub
commit ca52a2e073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,11 +79,16 @@ class LiveResult extends PureComponent {
if (responses) {
const response = responses.find(r => r.userId === user.userId);
if (response) {
const answerKeys = [];
const formattedAnswers = [];
response.answerIds.forEach((answerId) => {
answerKeys.push(answers[answerId].key);
const formattedMessageIndex = answers[answerId].key.toLowerCase();
const formattedAnswer = defaultPoll && pollAnswerIds[formattedMessageIndex]
? intl.formatMessage(pollAnswerIds[formattedMessageIndex])
: answers[answerId].key;
formattedAnswers.push(formattedAnswer);
});
answer = answerKeys.join(', ');
answer = formattedAnswers.join(', ');
}
}
@ -94,18 +99,13 @@ class LiveResult extends PureComponent {
})
.sort(Service.sortUsers)
.reduce((acc, user) => {
const formattedMessageIndex = user.answer.toLowerCase();
return ([
...acc,
(
<tr key={_.uniqueId('stats-')}>
<Styled.ResultLeft>{user.name}</Styled.ResultLeft>
<Styled.ResultRight data-test="receivedAnswer">
{
defaultPoll && pollAnswerIds[formattedMessageIndex]
? intl.formatMessage(pollAnswerIds[formattedMessageIndex])
: user.answer
}
{user.answer}
</Styled.ResultRight>
</tr>
),