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/edit_post_modal.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/edit_post_modal.jsx')
-rw-r--r-- | web/react/components/edit_post_modal.jsx | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/web/react/components/edit_post_modal.jsx b/web/react/components/edit_post_modal.jsx index 39d058f30..8ffd5013a 100644 --- a/web/react/components/edit_post_modal.jsx +++ b/web/react/components/edit_post_modal.jsx @@ -39,17 +39,9 @@ module.exports = React.createClass({ $(this.state.refocusId).focus(); }, handleEditInput: function(editText) { - var newError = this.state.error; - - var len = utils.getLengthOfTextInTextarea(editText); - - if (!this.state.error && len >= Constants.MAX_POST_LEN) { - newError = 'New message length cannot exceed 4000 characters'; - } else if (this.state.error === 'New message length cannot exceed 4000 characters' && len < Constants.MAX_POST_LEN) { - newError = ''; - } - - this.setState({editText: editText, error: newError}); + var editMessage = utils.truncateText(editText); + var newError = utils.checkMessageLengthError(editMessage, this.state.error, 'New message length cannot exceed ' + Constants.MAX_POST_LEN + ' characters'); + this.setState({editText: editMessage, error: newError}); }, handleEditKeyPress: function(e) { if (e.which == 13 && !e.shiftKey && !e.altKey) { |