From 52e929cad3e2c5944668ef19275692f59437648d Mon Sep 17 00:00:00 2001 From: Brayden Williams <1311325+redstar504@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:22:35 -0800 Subject: [PATCH] Rename the comment length function --- src/libs/ReportUtils.js | 14 +++++++------- src/pages/home/report/ReportActionCompose.js | 4 ++-- .../home/report/ReportActionItemMessageEdit.js | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 82e4d1329c31..05a94a8ab6f1 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1372,12 +1372,12 @@ function getNewMarkerReportActionID(report, sortedAndFilteredReportActions) { } /** - * Replace code points > 127 with C escape sequences, and return the resulting string's overall length - * Used for compatibility with the backend auth validator for AddComment - * @param {String} textComment - * @returns {Number} - */ -function commentLength(textComment) { + * Replace code points > 127 with C escape sequences, and return the resulting string's overall length + * Used for compatibility with the backend auth validator for AddComment + * @param {String} textComment + * @returns {Number} + */ +function getCommentLength(textComment) { return textComment.replace(/[^ -~]/g, '\\u????').length; } @@ -1435,5 +1435,5 @@ export { getOldDotDefaultAvatar, getNewMarkerReportActionID, canSeeDefaultRoom, - commentLength, + getCommentLength, }; diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index fa9e7255e2ce..9c5ec671cb74 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -471,7 +471,7 @@ class ReportActionCompose extends React.Component { const trimmedComment = this.comment.trim(); // Don't submit empty comments or comments that exceed the character limit - if (this.state.isCommentEmpty || ReportUtils.commentLength(trimmedComment) > CONST.MAX_COMMENT_LENGTH) { + if (this.state.isCommentEmpty || ReportUtils.getCommentLength(trimmedComment) > CONST.MAX_COMMENT_LENGTH) { return ''; } @@ -534,7 +534,7 @@ class ReportActionCompose extends React.Component { const isComposeDisabled = this.props.isDrawerOpen && this.props.isSmallScreenWidth; const isBlockedFromConcierge = ReportUtils.chatIncludesConcierge(this.props.report) && User.isBlockedFromConcierge(this.props.blockedFromConcierge); const inputPlaceholder = this.getInputPlaceholder(); - const encodedCommentLength = ReportUtils.commentLength(this.comment); + const encodedCommentLength = ReportUtils.getCommentLength(this.comment); const hasExceededMaxCommentLength = encodedCommentLength > CONST.MAX_COMMENT_LENGTH; return ( diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index 5d2aae43bde2..5f6b5e36632e 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -155,7 +155,7 @@ class ReportActionItemMessageEdit extends React.Component { */ publishDraft() { // Do nothing if draft exceed the character limit - if (ReportUtils.commentLength(this.state.draft) > CONST.MAX_COMMENT_LENGTH) { + if (ReportUtils.getCommentLength(this.state.draft) > CONST.MAX_COMMENT_LENGTH) { return; } @@ -215,7 +215,7 @@ class ReportActionItemMessageEdit extends React.Component { } render() { - const draftLength = ReportUtils.commentLength(this.state.draft); + const draftLength = ReportUtils.getCommentLength(this.state.draft); const hasExceededMaxCommentLength = draftLength > CONST.MAX_COMMENT_LENGTH; return (