-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix last message text in LHN includes text and no space above quoted text #8814
Conversation
src/libs/actions/Report.js
Outdated
let messageText = lodashGet(reportAction, ['message', 0, 'html'], ''); | ||
if (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED) { | ||
messageText = lodashGet(reportAction, 'originalMessage.html', ''); | ||
} | ||
|
||
const parser = new ExpensiMark(); | ||
messageText = parser.htmlToText(messageText); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this change should be done at the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parasharrajat Yeah probably, any suggestion on what we should do then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Luke9389 should we do the correct on the backend as well? The backend already converts the HTML to text and then sends it frontend. It does not use the text that we send in the action instead do the conversion itself. So I think we should also make the correction on the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was OOO last week. Just checking this one out. One moment....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, yea. I agree this should be done on the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Luke9389 @parasharrajat How do we do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll have to make a PR because our backend isn't open-source.
I'm just looking into how we prep the text
value of that message
key. It doesn't look like we import the Expensimark
lib at all in that file.
I'll come back and update you guys when that change has been deployed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sorry to flipflop here, but I think this is actually fine to do on the front end. We're using the strip_tags
PHP method on the back end, and changing that to pick up on </blockquote>
specifically is not going to be pretty, and seems inappropriate.
src/libs/actions/ReportActions.js
Outdated
const parser = new ExpensiMark(); | ||
const lastMessageIndex = _.findLastIndex(reportActions[reportID], action => ( | ||
!ReportUtils.isDeletedAction(action) | ||
)); | ||
const htmlText = lodashGet(reportActions, [reportID, lastMessageIndex, 'message', 0, 'html'], ''); | ||
const messageText = parser.htmlToText(htmlText); | ||
|
||
return ReportUtils.formatReportLastMessageText( | ||
lodashGet(reportActions, [reportID, lastMessageIndex, 'message', 0, 'text'], ''), | ||
); | ||
return ReportUtils.formatReportLastMessageText(messageText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do the previous change, then we won't need this.
@mollfpr We can [Hold] on the PR title. |
@Luke9389 Any update for the API? |
Still on hold. Feel free to take other jobs in the meantime @mollfpr |
Took this off HOLD, feel free to continue. Sorry for the long delay here @mollfpr |
@Luke9389 No problem! 👍 |
Please merge main. |
src/libs/actions/Report.js
Outdated
@@ -548,9 +547,12 @@ function updateReportWithNewAction( | |||
reportAction, | |||
notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, | |||
) { | |||
const messageText = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED | |||
let messageText = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let messageText = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED | |
let messageHtml = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch 👍
src/libs/actions/Report.js
Outdated
lastMessageText = lastActionMessage | ||
.replace(/((<br[^>]*>)+)/gi, ' ') | ||
.replace(/(<([^>]+)>)/gi, ''); | ||
// We convert the line-breaks and blockquote closing tag in html to space ' ' before striping the tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment makes sense here. This is best suited for htmlToText
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this as well
App/src/libs/actions/Report.js
Line 1264 in f26cd0c
newReportAction.message[0].text = Str.stripHTML(htmlForNewComment.replace(/((<br[^>]*>)+)/gi, ' ')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mollfpr Improve the QA steps. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
: lodashGet(reportAction, ['message', 0, 'html'], ''); | ||
|
||
const parser = new ExpensiMark(); | ||
const messageText = parser.htmlToText(messageHtml); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Deployed to production by @roryabraham in version: 1.1.75-1 🚀
|
Details
Using
htmlToText
from ExpensifyMark to replace breakline and blockquote closing tag to space ' ', strip out tags.Fixed Issues
$ #8134
Tests
Confusing stuff Tell me about it
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
filesSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)PR Reviewer Checklist
### Fixed Issues
section aboveTests
sectionQA steps
sectiontoggleReport
and notonIconClick
).src/languages/*
filesSTYLE.md
) were followed/** comment above it */
displayName
propertythis
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)QA Steps
Confusing stuff Tell me about it
Screenshots
Web
screen-recording-2022-04-28-at-012537_TXS8ZwSl.mp4
Mobile Web
screen-recording-2022-04-28-at-115143_xnEOINzG.mp4
screen-recording-2022-04-28-at-115102_yu2dZd3t.mp4
Desktop
screen-recording-2022-04-28-at-115536_c5bFvKI6.mp4
iOS
screen-recording-2022-04-28-at-013409_GM3xdxCi.mp4
Android
screen-recording-2022-04-28-at-014003_Vib6YZX0.mp4