From a56603d666a4f3e22a92a0271eef56ab613ce848 Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Wed, 26 Aug 2015 09:38:06 -0700
Subject: Moved duplicate code into functions and added better handling of
 large paste text dumps

---
 web/react/components/create_post.jsx | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

(limited to 'web/react/components/create_post.jsx')

diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx
index 387149b14..19270197e 100644
--- a/web/react/components/create_post.jsx
+++ b/web/react/components/create_post.jsx
@@ -18,6 +18,7 @@ var Constants = require('../utils/constants.jsx');
 var ActionTypes = Constants.ActionTypes;
 
 module.exports = React.createClass({
+    displayName: 'CreatePost',
     lastTime: 0,
     handleSubmit: function(e) {
         e.preventDefault();
@@ -131,16 +132,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 = 'Message length cannot exceed 4000 characters';
-        } else if (this.state.postError === 'Message 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, 'Message length cannot exceed ' + Constants.MAX_POST_LEN + ' characters');
 
         this.resizePostHolder();
         this.setState({messageText: messageText, postError: newPostError});
-- 
cgit v1.2.3-1-g7c22

