From 5766bbfc65e3f6663737da5d15359d68e3f991ff Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Mon, 24 Aug 2015 20:47:27 -0700
Subject: Prevents users from typing more than 4000 characters into any
 'textbox' (posts, comments, and post/comment edits).  Also adds new error
 message for when users hit exactly 4000 characters so they know the limit.

---
 web/react/components/create_post.jsx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(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 efaa40577..242513d07 100644
--- a/web/react/components/create_post.jsx
+++ b/web/react/components/create_post.jsx
@@ -132,8 +132,16 @@ module.exports = React.createClass({
         }
     },
     handleUserInput: function(messageText) {
+        var newPostError = this.state.postError;
+
+        if (!this.state.postError && messageText.length >= Constants.MAX_POST_LEN) {
+            newPostError = 'Message length cannot exceed 4000 characters';
+        } else if (this.state.postError === 'Message length cannot exceed 4000 characters' && messageText.length < Constants.MAX_POST_LEN) {
+            newPostError = '';
+        }
+
         this.resizePostHolder();
-        this.setState({messageText: messageText});
+        this.setState({messageText: messageText, postError: newPostError});
 
         var draft = PostStore.getCurrentDraft();
         draft['message'] = messageText;
-- 
cgit v1.2.3-1-g7c22


From 656a88efdd2606ce8449097e740535f41aee9d64 Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Tue, 25 Aug 2015 12:47:18 -0700
Subject: Fixed issue with carriage returns being counted improperly in non-ie
 browsers and updated error messages to be appropriate to what is being typed
 (message vs. post vs. edit)

---
 web/react/components/create_post.jsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 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 242513d07..387149b14 100644
--- a/web/react/components/create_post.jsx
+++ b/web/react/components/create_post.jsx
@@ -134,9 +134,11 @@ module.exports = React.createClass({
     handleUserInput: function(messageText) {
         var newPostError = this.state.postError;
 
-        if (!this.state.postError && messageText.length >= Constants.MAX_POST_LEN) {
+        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' && messageText.length < Constants.MAX_POST_LEN) {
+        } else if (this.state.postError === 'Message length cannot exceed 4000 characters' && len < Constants.MAX_POST_LEN) {
             newPostError = '';
         }
 
-- 
cgit v1.2.3-1-g7c22


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

