diff options
author | JoramWilander <jwawilander@gmail.com> | 2015-07-23 09:39:29 -0400 |
---|---|---|
committer | JoramWilander <jwawilander@gmail.com> | 2015-08-18 08:58:02 -0400 |
commit | 32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9 (patch) | |
tree | 1203fd854bf7ea843a35ce52382b0846ffa3873a /web/react/components/post_list.jsx | |
parent | 4805608cc9cf79277f37b94bbe38398816469884 (diff) | |
download | chat-32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9.tar.gz chat-32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9.tar.bz2 chat-32f7b50bb5c62d27def3f2e6d2839511c0b8f9a9.zip |
adds predictive posting on the client
Diffstat (limited to 'web/react/components/post_list.jsx')
-rw-r--r-- | web/react/components/post_list.jsx | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx index 8c76eb82c..834d7b0ff 100644 --- a/web/react/components/post_list.jsx +++ b/web/react/components/post_list.jsx @@ -20,8 +20,16 @@ function getStateFromStores() { if (channel == null) channel = {}; + var post_list = PostStore.getCurrentPosts(); + var pending_post_list = PostStore.getPendingPosts(channel.id); + + if (pending_post_list) { + post_list.order = pending_post_list.order.concat(post_list.order); + for (var pid in pending_post_list.posts) { post_list.posts[pid] = pending_post_list.posts[pid] }; + } + return { - post_list: PostStore.getCurrentPosts(), + post_list: post_list, channel: channel }; } @@ -186,8 +194,16 @@ module.exports = React.createClass({ if (msg.action == "posted") { var post = JSON.parse(msg.props.post); - var post_list = PostStore.getPosts(msg.channel_id); - if (!post_list) return; + if (post.pending_post_id !== "") { + PostStore.removePendingPost(post.channel_id, post.pending_post_id); + } + + post.pending_post_id = ""; + + postList.posts[post.id] = post; + if (postList.order.indexOf(post.id) === -1) { + postList.order.unshift(post.id); + } post_list.posts[post.id] = post; if (post_list.order.indexOf(post.id) === -1) { @@ -456,7 +472,9 @@ module.exports = React.createClass({ ); } - if (post.create_at > last_viewed && !rendered_last_viewed) { + var userId = UserStore.getCurrentId(); + + if (post.user_id !== userId && post.create_at > last_viewed && !rendered_last_viewed) { rendered_last_viewed = true; postCtls.push( <div key="unviewed" className="new-separator"> |