diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2015-11-02 14:20:54 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2015-11-02 14:20:54 -0500 |
commit | e52669c2da0bb78c225a5c87edebe472e4c7ac56 (patch) | |
tree | a311de9975f99ab26396510c7261bfc30f799495 /web/react/stores | |
parent | 31eee1ef6ebb59a89885ef7e3ebd6801f9a396d4 (diff) | |
parent | d4ec6d3bf42d257851304fe9588f2db8bbbefa13 (diff) | |
download | chat-e52669c2da0bb78c225a5c87edebe472e4c7ac56.tar.gz chat-e52669c2da0bb78c225a5c87edebe472e4c7ac56.tar.bz2 chat-e52669c2da0bb78c225a5c87edebe472e4c7ac56.zip |
Merge pull request #1249 from mattermost/plt-823
PLT-823 Refactor of center channel
Diffstat (limited to 'web/react/stores')
-rw-r--r-- | web/react/stores/post_store.jsx | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx index 8f4e30e7c..0fe253310 100644 --- a/web/react/stores/post_store.jsx +++ b/web/react/stores/post_store.jsx @@ -14,6 +14,7 @@ var ActionTypes = Constants.ActionTypes; var CHANGE_EVENT = 'change'; var SELECTED_POST_CHANGE_EVENT = 'selected_post_change'; var EDIT_POST_EVENT = 'edit_post'; +var POSTS_VIEW_JUMP_EVENT = 'post_list_jump'; class PostStoreClass extends EventEmitter { constructor() { @@ -29,7 +30,11 @@ class PostStoreClass extends EventEmitter { this.emitEditPost = this.emitEditPost.bind(this); this.addEditPostListener = this.addEditPostListener.bind(this); - this.removeEditPostListener = this.removeEditPostListener.bind(this); + this.removeEditPostListener = this.removeEditPostListner.bind(this); + + this.emitPostsViewJump = this.emitPostsViewJump.bind(this); + this.addPostsViewJumpListener = this.addPostsViewJumpListener.bind(this); + this.removePostsViewJumpListener = this.removePostsViewJumpListener.bind(this); this.getCurrentPosts = this.getCurrentPosts.bind(this); this.storePosts = this.storePosts.bind(this); @@ -96,10 +101,34 @@ class PostStoreClass extends EventEmitter { this.on(EDIT_POST_EVENT, callback); } - removeEditPostListener(callback) { + removeEditPostListner(callback) { this.removeListener(EDIT_POST_EVENT, callback); } + emitPostsViewJump(type, post) { + this.emit(POSTS_VIEW_JUMP_EVENT, type, post); + } + + addPostsViewJumpListener(callback) { + this.on(POSTS_VIEW_JUMP_EVENT, callback); + } + + removePostsViewJumpListener(callback) { + this.removeListener(POSTS_VIEW_JUMP_EVENT, callback); + } + + jumpPostsViewToBottom() { + this.emitPostsViewJump(Constants.PostsViewJumpTypes.BOTTOM, null); + } + + jumpPostsViewToPost(post) { + this.emitPostsViewJump(Constants.PostsViewJumpTypes.POST, post); + } + + jumpPostsViewSidebarOpen() { + this.emitPostsViewJump(Constants.PostsViewJumpTypes.SIDEBAR_OPEN, null); + } + getCurrentPosts() { var currentId = ChannelStore.getCurrentId(); @@ -108,16 +137,16 @@ class PostStoreClass extends EventEmitter { } return null; } - storePosts(channelId, newPostList) { - if (isPostListNull(newPostList)) { + storePosts(channelId, newPostsView) { + if (isPostListNull(newPostsView)) { return; } var postList = makePostListNonNull(this.getPosts(channelId)); - for (const pid in newPostList.posts) { - if (newPostList.posts.hasOwnProperty(pid)) { - const np = newPostList.posts[pid]; + for (const pid in newPostsView.posts) { + if (newPostsView.posts.hasOwnProperty(pid)) { + const np = newPostsView.posts[pid]; if (np.delete_at === 0) { postList.posts[pid] = np; if (postList.order.indexOf(pid) === -1) { |