diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-07-23 12:45:08 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-08-18 08:58:31 -0400 |
commit | 5596a6b37c440522176fdc05217161d7de7e169c (patch) | |
tree | 934ea924e0096d7d49621163c07da46ed67b68ac /web/react/components/create_comment.jsx | |
parent | 32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9 (diff) | |
download | chat-5596a6b37c440522176fdc05217161d7de7e169c.tar.gz chat-5596a6b37c440522176fdc05217161d7de7e169c.tar.bz2 chat-5596a6b37c440522176fdc05217161d7de7e169c.zip |
added client predictive commenting
Diffstat (limited to 'web/react/components/create_comment.jsx')
-rw-r--r-- | web/react/components/create_comment.jsx | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index 885efab7a..fbb05c77f 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -2,15 +2,16 @@ // See License.txt for license information. var client = require('../utils/client.jsx'); -var AsyncClient =require('../utils/async_client.jsx'); +var AsyncClient = require('../utils/async_client.jsx'); var SocketStore = require('../stores/socket_store.jsx'); var ChannelStore = require('../stores/channel_store.jsx'); +var UserStore = require('../stores/user_store.jsx'); var PostStore = require('../stores/post_store.jsx'); var Textbox = require('./textbox.jsx'); var MsgTyping = require('./msg_typing.jsx'); var FileUpload = require('./file_upload.jsx'); var FilePreview = require('./file_preview.jsx'); - +var utils = require('../utils/utils.jsx'); var Constants = require('../utils/constants.jsx'); module.exports = React.createClass({ @@ -39,10 +40,16 @@ module.exports = React.createClass({ return; } + var user_id = UserStore.getCurrentId(); + post.channel_id = this.props.channelId; post.root_id = this.props.rootId; - post.parent_id = this.props.parentId; + post.parent_id = this.props.rootId; post.filenames = this.state.previews; + var time = utils.getTimestamp(); + post.pending_post_id = user_id + ":"+ time; + post.user_id = user_id; + post.create_at = time; this.setState({submitting: true, serverError: null}); @@ -69,10 +76,19 @@ module.exports = React.createClass({ $('#post_deleted').modal('show'); } } else { - this.setState(state); + post.did_fail = true; + PostStore.updatePendingPost(post); } + + state.submitting = false; + this.setState(state); }.bind(this) ); + + post.is_loading = true; + PostStore.storePendingPost(post); + PostStore.storeCommentDraft(this.props.rootId, null); + this.setState({ messageText: '', submitting: false, post_error: null, previews: [], server_error: null, limit_error: null }); }, commentMsgKeyPress: function(e) { if (e.which === 13 && !e.shiftKey && !e.altKey) { |