diff options
Diffstat (limited to 'web/react/stores')
-rw-r--r-- | web/react/stores/post_store.jsx | 43 | ||||
-rw-r--r-- | web/react/stores/socket_store.jsx | 6 |
2 files changed, 40 insertions, 9 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) { diff --git a/web/react/stores/socket_store.jsx b/web/react/stores/socket_store.jsx index 4d69a6716..4efeb7c8f 100644 --- a/web/react/stores/socket_store.jsx +++ b/web/react/stores/socket_store.jsx @@ -165,7 +165,7 @@ function handleNewPostEvent(msg) { } // Send desktop notification - if (UserStore.getCurrentId() !== msg.user_id) { + if (UserStore.getCurrentId() !== msg.user_id || post.props.from_webhook === 'true') { const msgProps = msg.props; let mentions = []; @@ -189,7 +189,9 @@ function handleNewPostEvent(msg) { } let username = 'Someone'; - if (UserStore.hasProfile(msg.user_id)) { + if (post.props.override_username && global.window.mm_config.EnablePostUsernameOverride === 'true') { + username = post.props.override_username; + } else if (UserStore.hasProfile(msg.user_id)) { username = UserStore.getProfile(msg.user_id).username; } |