diff options
author | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-08-26 09:38:06 -0700 |
---|---|---|
committer | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-08-26 16:53:19 -0700 |
commit | a56603d666a4f3e22a92a0271eef56ab613ce848 (patch) | |
tree | 668afe7ba9fd1cd2f1a71f4da76247eb77f9c483 /web/react/components/create_comment.jsx | |
parent | 656a88efdd2606ce8449097e740535f41aee9d64 (diff) | |
download | chat-a56603d666a4f3e22a92a0271eef56ab613ce848.tar.gz chat-a56603d666a4f3e22a92a0271eef56ab613ce848.tar.bz2 chat-a56603d666a4f3e22a92a0271eef56ab613ce848.zip |
Moved duplicate code into functions and added better handling of large paste text dumps
Diffstat (limited to 'web/react/components/create_comment.jsx')
-rw-r--r-- | web/react/components/create_comment.jsx | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index 68bee800a..94b6e1b7f 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -105,16 +105,9 @@ module.exports = React.createClass({ this.lastTime = t; } }, - handleUserInput: function(messageText) { - var newPostError = this.state.postError; - - var len = utils.getLengthOfTextInTextarea(messageText); - - if (!this.state.postError && len >= Constants.MAX_POST_LEN) { - newPostError = 'Comment length cannot exceed 4000 characters'; - } else if (this.state.postError === 'Comment length cannot exceed 4000 characters' && len < Constants.MAX_POST_LEN) { - newPostError = ''; - } + handleUserInput: function(message) { + var messageText = utils.truncateText(message); + var newPostError = utils.checkMessageLengthError(messageText, this.state.postError, 'Comment length cannot exceed ' + Constants.MAX_POST_LEN + ' characters'); var draft = PostStore.getCommentDraft(this.props.rootId); draft.message = messageText; |