-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31769 from DylanDylann/fix/30921-no-error-message…
…-when-editing-a-chat Fix/30921: No error message when editing a chat
- Loading branch information
Showing
5 changed files
with
48 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import _ from 'lodash'; | ||
import {useCallback, useMemo, useState} from 'react'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import CONST from '@src/CONST'; | ||
|
||
const useHandleExceedMaxCommentLength = () => { | ||
const [hasExceededMaxCommentLength, setHasExceededMaxCommentLength] = useState(false); | ||
|
||
const handleValueChange = useCallback( | ||
(value: string) => { | ||
if (ReportUtils.getCommentLength(value) <= CONST.MAX_COMMENT_LENGTH) { | ||
if (hasExceededMaxCommentLength) { | ||
setHasExceededMaxCommentLength(false); | ||
} | ||
return; | ||
} | ||
setHasExceededMaxCommentLength(true); | ||
}, | ||
[hasExceededMaxCommentLength], | ||
); | ||
|
||
const validateCommentMaxLength = useMemo(() => _.debounce(handleValueChange, 1500), [handleValueChange]); | ||
|
||
return {hasExceededMaxCommentLength, validateCommentMaxLength}; | ||
}; | ||
|
||
export default useHandleExceedMaxCommentLength; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters