summaryrefslogtreecommitdiffstats
path: root/web/react/components/post.jsx
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-07-23 09:39:29 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-18 08:58:02 -0400
commit32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9 (patch)
tree1203fd854bf7ea843a35ce52382b0846ffa3873a /web/react/components/post.jsx
parent4805608cc9cf79277f37b94bbe38398816469884 (diff)
downloadchat-32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9.tar.gz
chat-32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9.tar.bz2
chat-32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9.zip
adds predictive posting on the client
Diffstat (limited to 'web/react/components/post.jsx')
-rw-r--r--web/react/components/post.jsx31
1 files changed, 30 insertions, 1 deletions
diff --git a/web/react/components/post.jsx b/web/react/components/post.jsx
index f099c67ab..c985eaeb2 100644
--- a/web/react/components/post.jsx
+++ b/web/react/components/post.jsx
@@ -7,6 +7,10 @@ var PostInfo = require('./post_info.jsx');
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
var Constants = require('../utils/constants.jsx');
var UserStore = require('../stores/user_store.jsx');
+var PostStore = require('../stores/post_store.jsx');
+var ChannelStore = require('../stores/channel_store.jsx');
+var client = require('../utils/client.jsx');
+var AsyncClient = require('../utils/async_client.jsx');
var ActionTypes = Constants.ActionTypes;
module.exports = React.createClass({
@@ -32,6 +36,31 @@ module.exports = React.createClass({
this.refs.info.forceUpdate();
this.refs.header.forceUpdate();
},
+ retryPost: function(e) {
+ e.preventDefault();
+
+ var post = this.props.post;
+ client.createPost(post, post.channel_id,
+ function(data) {
+ AsyncClient.getPosts(true);
+
+ var member = ChannelStore.getMember(post.channel_id);
+ member.msg_count = channel.total_msg_count;
+ member.last_viewed_at = (new Date).getTime();
+ ChannelStore.setChannelMember(member);
+ }.bind(this),
+ function(err) {
+ post.did_fail = true;
+ PostStore.updatePendingPost(post);
+ this.forceUpdate();
+ }.bind(this)
+ );
+
+ post.did_fail = false;
+ post.is_loading = true;
+ PostStore.updatePendingPost(post);
+ this.forceUpdate();
+ },
getInitialState: function() {
return { };
},
@@ -79,7 +108,7 @@ module.exports = React.createClass({
: null }
<div className="post__content">
<PostHeader ref="header" post={post} sameRoot={this.props.sameRoot} commentCount={commentCount} handleCommentClick={this.handleCommentClick} isLastComment={this.props.isLastComment} />
- <PostBody post={post} sameRoot={this.props.sameRoot} parentPost={parentPost} posts={posts} handleCommentClick={this.handleCommentClick} />
+ <PostBody post={post} sameRoot={this.props.sameRoot} parentPost={parentPost} posts={posts} handleCommentClick={this.handleCommentClick} retryPost={this.retryPost} />
<PostInfo ref="info" post={post} sameRoot={this.props.sameRoot} commentCount={commentCount} handleCommentClick={this.handleCommentClick} allowReply="true" />
</div>
</div>