diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-07-10 17:35:50 -0400 |
---|---|---|
committer | Saturnino Abril <saturnino.abril@gmail.com> | 2017-07-11 05:35:50 +0800 |
commit | 0c910cc8c5a5487a129663431c6cd4d52640bd66 (patch) | |
tree | 6a7c2e043afebc8768ff606211199a18060b9ddb /webapp | |
parent | 2190a288e004e46cddac992fc799dc1ae37fd4f3 (diff) | |
download | chat-0c910cc8c5a5487a129663431c6cd4d52640bd66.tar.gz chat-0c910cc8c5a5487a129663431c6cd4d52640bd66.tar.bz2 chat-0c910cc8c5a5487a129663431c6cd4d52640bd66.zip |
Fix multiple pinned post issues (#6887)
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/actions/post_actions.jsx | 20 | ||||
-rw-r--r-- | webapp/components/dot_menu/index.js | 3 | ||||
-rw-r--r-- | webapp/components/sidebar_right/sidebar_right.jsx | 4 |
3 files changed, 24 insertions, 3 deletions
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx index 87d9ed739..a32fee616 100644 --- a/webapp/actions/post_actions.jsx +++ b/webapp/actions/post_actions.jsx @@ -329,3 +329,23 @@ export function searchForTerm(term) { do_search: true }); } + +export function pinPost(postId) { + return async (doDispatch, doGetState) => { + await PostActions.pinPost(postId)(doDispatch, doGetState); + + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_POST_PINNED + }); + }; +} + +export function unpinPost(postId) { + return async (doDispatch, doGetState) => { + await PostActions.unpinPost(postId)(doDispatch, doGetState); + + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_POST_UNPINNED + }); + }; +} diff --git a/webapp/components/dot_menu/index.js b/webapp/components/dot_menu/index.js index eaa1e8d2c..852fe6791 100644 --- a/webapp/components/dot_menu/index.js +++ b/webapp/components/dot_menu/index.js @@ -3,7 +3,8 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; -import {flagPost, unflagPost, pinPost, unpinPost} from 'mattermost-redux/actions/posts'; +import {flagPost, unflagPost} from 'mattermost-redux/actions/posts'; +import {pinPost, unpinPost} from 'actions/post_actions.jsx'; import DotMenu from './dot_menu.jsx'; diff --git a/webapp/components/sidebar_right/sidebar_right.jsx b/webapp/components/sidebar_right/sidebar_right.jsx index 21d3df345..737254682 100644 --- a/webapp/components/sidebar_right/sidebar_right.jsx +++ b/webapp/components/sidebar_right/sidebar_right.jsx @@ -77,12 +77,12 @@ export default class SidebarRight extends React.Component { } shouldComponentUpdate(nextProps, nextState) { - return !Utils.areObjectsEqual(nextState, this.state) || !Utils.areObjectsEqual(nextProps, this.props); + return !Utils.areObjectsEqual(nextState, this.state) || this.props.postRightVisible !== nextProps.postRightVisible; } componentWillUpdate(nextProps, nextState) { const isOpen = this.state.searchVisible || this.props.postRightVisible; - const willOpen = nextState.searchVisible || nextState.postRightVisible; + const willOpen = nextState.searchVisible || nextProps.postRightVisible; if (!isOpen && willOpen) { trackEvent('ui', 'ui_rhs_opened'); |