summaryrefslogtreecommitdiffstats
path: root/web/react/components/create_comment.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/components/create_comment.jsx')
-rw-r--r--web/react/components/create_comment.jsx14
1 files changed, 8 insertions, 6 deletions
diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx
index 1de768872..f6e34fda9 100644
--- a/web/react/components/create_comment.jsx
+++ b/web/react/components/create_comment.jsx
@@ -29,8 +29,6 @@ module.exports = React.createClass({
return;
}
- this.setState({submitting: true, serverError: null});
-
var post = {};
post.filenames = [];
post.message = this.state.messageText;
@@ -57,11 +55,10 @@ module.exports = React.createClass({
PostStore.storePendingPost(post);
PostStore.storeCommentDraft(this.props.rootId, null);
- this.setState({messageText: '', submitting: false, postError: null, previews: [], serverError: null});
client.createPost(post, ChannelStore.getCurrent(),
function(data) {
- AsyncClient.getPosts(true, this.props.channelId);
+ AsyncClient.getPosts(this.props.channelId);
var channel = ChannelStore.get(this.props.channelId);
var member = ChannelStore.getMember(this.props.channelId);
@@ -91,6 +88,8 @@ module.exports = React.createClass({
this.setState(state);
}.bind(this)
);
+
+ this.setState({messageText: '', submitting: false, postError: null, previews: [], serverError: null});
},
commentMsgKeyPress: function(e) {
if (e.which === 13 && !e.shiftKey && !e.altKey) {
@@ -105,14 +104,17 @@ module.exports = React.createClass({
this.lastTime = t;
}
},
- handleUserInput: function(messageText) {
+ 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;
PostStore.storeCommentDraft(this.props.rootId, draft);
$('.post-right__scroll').scrollTop($('.post-right__scroll')[0].scrollHeight);
$('.post-right__scroll').perfectScrollbar('update');
- this.setState({messageText: messageText});
+ this.setState({messageText: messageText, postError: newPostError});
},
handleUploadStart: function(clientIds, channelId) {
var draft = PostStore.getCommentDraft(this.props.rootId);