Skip to content

Commit

Permalink
move limit to const
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Apr 20, 2022
1 parent 1ef69a1 commit 2517aca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ const CONST = {
this.EMAIL.ADMIN,
];
},

// There's a limit of 60k characters in Auth - https://github.com/Expensify/Auth/blob/198d59547f71fdee8121325e8bc9241fc9c3236a/auth/lib/Request.h#L28
MAX_COMMENT_LENGTH: 60_000,
};

export default CONST;
9 changes: 3 additions & 6 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ class ReportActionCompose extends React.Component {
this.setTextInputRef = this.setTextInputRef.bind(this);
this.getInputPlaceholder = this.getInputPlaceholder.bind(this);

// There's a limit of 60k characters in Auth - https://github.com/Expensify/Auth/blob/198d59547f71fdee8121325e8bc9241fc9c3236a/auth/lib/Request.h#L28
this.maxCommentLength = 60_000;

this.state = {
isFocused: this.shouldFocusInputOnScreenFocus,
textInputShouldClear: false,
Expand Down Expand Up @@ -374,7 +371,7 @@ class ReportActionCompose extends React.Component {
const trimmedComment = this.comment.trim();

// Don't submit empty comments or comments that exceed the character limit
if (!trimmedComment || trimmedComment.length > this.maxCommentLength) {
if (!trimmedComment || trimmedComment.length > CONST.MAX_COMMENT_LENGTH) {
return;
}

Expand Down Expand Up @@ -404,7 +401,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 hasExceededMaxCommentLength = this.comment.length > this.maxCommentLength;
const hasExceededMaxCommentLength = this.comment.length > CONST.MAX_COMMENT_LENGTH;

return (
<View style={[shouldShowReportRecipientLocalTime && styles.chatItemComposeWithFirstRow]}>
Expand Down Expand Up @@ -610,7 +607,7 @@ class ReportActionCompose extends React.Component {
</View>
{hasExceededMaxCommentLength && (
<Text style={[styles.textMicro, styles.textDanger, styles.chatItemComposeSecondaryRow]}>
{`${this.comment.length}/${this.maxCommentLength}`}
{`${this.comment.length}/${CONST.MAX_COMMENT_LENGTH}`}
</Text>
)}
</View>
Expand Down

0 comments on commit 2517aca

Please sign in to comment.