Skip to content

Commit

Permalink
Rename the comment length function
Browse files Browse the repository at this point in the history
  • Loading branch information
redstar504 committed Feb 7, 2023
1 parent 31f8dc4 commit 52e929c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -1435,5 +1435,5 @@ export {
getOldDotDefaultAvatar,
getNewMarkerReportActionID,
canSeeDefaultRoom,
commentLength,
getCommentLength,
};
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

Expand Down Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 (
<View style={styles.chatItemMessage}>
Expand Down

0 comments on commit 52e929c

Please sign in to comment.