Moved duplicate code into functions and added better handling of large paste text dumps

Этот коммит содержится в:
Reed Garmsen
2015-08-26 09:38:06 -07:00
родитель 656a88efdd
Коммит a56603d666
4 изменённых файлов: 34 добавлений и 31 удалений

Просмотреть файл

@@ -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;