From cf9d0af1e45cdb39b471e147bc857aa62bb79e2b Mon Sep 17 00:00:00 2001 From: Sobit Neupane <073bct543.sobit@pcampus.edu.np> Date: Thu, 3 Feb 2022 21:40:43 +0545 Subject: [PATCH 1/4] Translate alternate text to Spanish --- src/components/OptionsList/BaseOptionsList.js | 7 ++++++- src/libs/OptionsListUtils.js | 1 + src/libs/actions/Report.js | 9 +++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/OptionsList/BaseOptionsList.js b/src/components/OptionsList/BaseOptionsList.js index e65b0034035a..65953c6417bd 100644 --- a/src/components/OptionsList/BaseOptionsList.js +++ b/src/components/OptionsList/BaseOptionsList.js @@ -7,6 +7,7 @@ import styles from '../../styles/styles'; import OptionRow from '../../pages/home/sidebar/OptionRow'; import SectionList from '../SectionList'; import Text from '../Text'; +import * as Localize from '../../libs/Localize'; import {propTypes as optionsListPropTypes, defaultProps as optionsListDefaultProps} from './optionsListPropTypes'; const propTypes = { @@ -97,9 +98,13 @@ class BaseOptionsList extends Component { * @return {Component} */ renderItem({item, index, section}) { + const updatedItem = item; + if (item.isLastMessageAttachment) { + updatedItem.alternateText = `[${Localize.translateLocal('common.attachment')}]`; + } return ( ]*>)+)/gi, ' ').replace(/<[^>]*>?/gm, ''); + // Remove HTML from text when applying optimistic offline comment + const lastMessageText = isAttachment ? Localize.translateLocal('common.attachment') : htmlForNewComment.replace(/((]*>)+)/gi, ' ').replace(/<[^>]*>?/gm, ''); + // Update the report in Onyx to have the new sequence number Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { maxSequenceNumber: newSequenceNumber, lastMessageTimestamp: moment().unix(), - lastMessageText: ReportUtils.formatReportLastMessageText(textForNewComment), + lastMessageText: ReportUtils.formatReportLastMessageText(lastMessageText), lastActorEmail: currentUserEmail, + isLastMessageAttachment: isAttachment, }); // Generate a clientID so we can save the optimistic action to storage with the clientID as key. Later, we will From 64dab20a609f61fd8b606647eb249a712eeb0f78 Mon Sep 17 00:00:00 2001 From: Sobit Neupane <073bct543.sobit@pcampus.edu.np> Date: Sun, 6 Feb 2022 19:22:59 +0545 Subject: [PATCH 2/4] Set alternateText to Attachment from OptionsListUtils if Attachment --- src/components/OptionsList/BaseOptionsList.js | 7 +------ src/libs/OptionsListUtils.js | 4 ++-- src/libs/actions/Report.js | 9 ++------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/components/OptionsList/BaseOptionsList.js b/src/components/OptionsList/BaseOptionsList.js index 65953c6417bd..e65b0034035a 100644 --- a/src/components/OptionsList/BaseOptionsList.js +++ b/src/components/OptionsList/BaseOptionsList.js @@ -7,7 +7,6 @@ import styles from '../../styles/styles'; import OptionRow from '../../pages/home/sidebar/OptionRow'; import SectionList from '../SectionList'; import Text from '../Text'; -import * as Localize from '../../libs/Localize'; import {propTypes as optionsListPropTypes, defaultProps as optionsListDefaultProps} from './optionsListPropTypes'; const propTypes = { @@ -98,13 +97,9 @@ class BaseOptionsList extends Component { * @return {Component} */ renderItem({item, index, section}) { - const updatedItem = item; - if (item.isLastMessageAttachment) { - updatedItem.alternateText = `[${Localize.translateLocal('common.attachment')}]`; - } return ( ]*>)+)/gi, ' ').replace(/<[^>]*>?/gm, ''); - // Remove HTML from text when applying optimistic offline comment - const lastMessageText = isAttachment ? Localize.translateLocal('common.attachment') : htmlForNewComment.replace(/((]*>)+)/gi, ' ').replace(/<[^>]*>?/gm, ''); - // Update the report in Onyx to have the new sequence number Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { maxSequenceNumber: newSequenceNumber, lastMessageTimestamp: moment().unix(), - lastMessageText: ReportUtils.formatReportLastMessageText(lastMessageText), + lastMessageText: ReportUtils.formatReportLastMessageText(textForNewComment), lastActorEmail: currentUserEmail, - isLastMessageAttachment: isAttachment, }); // Generate a clientID so we can save the optimistic action to storage with the clientID as key. Later, we will From 6188268df7723dc8c2bb68b500717b2a653c60b7 Mon Sep 17 00:00:00 2001 From: sobitneupane <073bct543.sobit@pcampus.edu.np> Date: Wed, 9 Feb 2022 19:14:49 +0545 Subject: [PATCH 3/4] Simplify ternary operator in lastMessageText --- src/libs/OptionsListUtils.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 2a2efd34e2e4..f28cf96ed957 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -227,12 +227,11 @@ function createOption(personalDetailList, report, { : {}; const lastActorDetails = report ? _.find(personalDetailList, {login: report.lastActorEmail}) : null; - const lastMessageText = report - ? (hasMultipleParticipants && lastActorDetails - ? `${lastActorDetails.displayName}: ` - : '') - + (isLastMessageAttachment ? `[${Localize.translateLocal('common.attachment')}]` : Str.htmlDecode(report.lastMessageText)) + const lastMessageTextFromReport = report && (isLastMessageAttachment ? `[${Localize.translateLocal('common.attachment')}]` : Str.htmlDecode(report.lastMessageText)); + let lastMessageText = report && hasMultipleParticipants && lastActorDetails + ? `${lastActorDetails.displayName}: ` : ''; + lastMessageText += report ? lastMessageTextFromReport : ''; const tooltipText = ReportUtils.getReportParticipantsTitle(lodashGet(report, ['participants'], [])); From 8ff224dd95b6b836b90e4138541708d17e933d0f Mon Sep 17 00:00:00 2001 From: sobitneupane <073bct543.sobit@pcampus.edu.np> Date: Wed, 9 Feb 2022 20:55:16 +0545 Subject: [PATCH 4/4] Syntatic Change in lastMessageTextFromReport --- src/libs/OptionsListUtils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index f28cf96ed957..f7a9e3441fbd 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -221,13 +221,14 @@ function createOption(personalDetailList, report, { const personalDetail = personalDetailList[0]; const hasDraftComment = hasReportDraftComment(report); const hasOutstandingIOU = lodashGet(report, 'hasOutstandingIOU', false); - const isLastMessageAttachment = report ? ReportUtils.isReportMessageAttachment(report.lastMessageText) : false; const iouReport = hasOutstandingIOU ? lodashGet(iouReports, `${ONYXKEYS.COLLECTION.REPORT_IOUS}${report.iouReportID}`, {}) : {}; const lastActorDetails = report ? _.find(personalDetailList, {login: report.lastActorEmail}) : null; - const lastMessageTextFromReport = report && (isLastMessageAttachment ? `[${Localize.translateLocal('common.attachment')}]` : Str.htmlDecode(report.lastMessageText)); + const lastMessageTextFromReport = ReportUtils.isReportMessageAttachment(lodashGet(report, 'lastMessageText', '')) + ? `[${Localize.translateLocal('common.attachment')}]` + : Str.htmlDecode(lodashGet(report, 'lastMessageText', '')); let lastMessageText = report && hasMultipleParticipants && lastActorDetails ? `${lastActorDetails.displayName}: ` : '';