From 960a5dced1c2959b7393298d070998709a0ca887 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Fri, 21 May 2021 07:54:12 +0530 Subject: [PATCH 1/2] chg: convert line-breaks to spaces in LHN message preview --- src/libs/actions/Report.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 3fb0c7f4f48c..2954cfa1f8ed 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -154,7 +154,10 @@ function getSimplifiedReportObject(report) { // We are removing any html tags from the message html since we cannot access the text version of any comments as // the report only has the raw reportActionList and not the processed version returned by Report_GetHistory - const lastMessageText = lodashGet(lastReportAction, ['message', 'html'], '').replace(/(<([^>]+)>)/gi, ''); + // We convert the line-breaks in html to space ' ' before striping the tags + const lastMessageText = lodashGet(lastReportAction, ['message', 'html'], '') + .replace(/(<(br[^>]*)>)/gi, ' ') + .replace(/(<([^>]+)>)/gi, ''); const reportName = lodashGet(report, 'reportNameValuePairs.type') === 'chat' ? getChatReportName(report.sharedReportList) : report.reportName; @@ -954,7 +957,7 @@ function addAction(reportID, text, file) { // Remove HTML from text when applying optimistic offline comment const textForNewComment = isAttachment ? '[Attachment]' - : htmlForNewComment.replace(/<[^>]*>?/gm, ''); + : htmlForNewComment.replace(/(<(br[^>]*)>)/gi, ' ').replace(/<[^>]*>?/gm, ''); // Update the report in Onyx to have the new sequence number Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { From 12cbca2d5b37475d8599283ed5cdc28c6e4784bf Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 22 May 2021 02:53:00 +0530 Subject: [PATCH 2/2] fix: combine multiple line breaks into one space --- src/libs/actions/Report.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 2954cfa1f8ed..11d3169f2289 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -156,7 +156,7 @@ function getSimplifiedReportObject(report) { // the report only has the raw reportActionList and not the processed version returned by Report_GetHistory // We convert the line-breaks in html to space ' ' before striping the tags const lastMessageText = lodashGet(lastReportAction, ['message', 'html'], '') - .replace(/(<(br[^>]*)>)/gi, ' ') + .replace(/((]*>)+)/gi, ' ') .replace(/(<([^>]+)>)/gi, ''); const reportName = lodashGet(report, 'reportNameValuePairs.type') === 'chat' ? getChatReportName(report.sharedReportList) @@ -957,7 +957,7 @@ function addAction(reportID, text, file) { // Remove HTML from text when applying optimistic offline comment const textForNewComment = isAttachment ? '[Attachment]' - : htmlForNewComment.replace(/(<(br[^>]*)>)/gi, ' ').replace(/<[^>]*>?/gm, ''); + : htmlForNewComment.replace(/((]*>)+)/gi, ' ').replace(/<[^>]*>?/gm, ''); // Update the report in Onyx to have the new sequence number Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { @@ -1155,7 +1155,7 @@ function editReportComment(reportID, originalReportAction, htmlForNewComment) { const actionToMerge = {}; newReportAction.message[0].isEdited = true; newReportAction.message[0].html = htmlForNewComment; - newReportAction.message[0].text = Str.stripHTML(htmlForNewComment); + newReportAction.message[0].text = Str.stripHTML(htmlForNewComment.replace(/((]*>)+)/gi, ' ')); actionToMerge[sequenceNumber] = newReportAction; Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, actionToMerge);