diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-02-23 14:34:06 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-02-23 14:34:06 -0500 |
commit | 0031c6fd1a4df621cbecfd2a2b3efe9a40cd49ce (patch) | |
tree | 2afcb0888267be4cf59df2d0e8f5085d6aacccb0 /web/react/components/posts_view.jsx | |
parent | 11093ddb51a70622287aac20108be6c6aa2eb76d (diff) | |
parent | 1f049af2b7ea41a5e1e79a8263e10fa58f186c8d (diff) | |
download | chat-0031c6fd1a4df621cbecfd2a2b3efe9a40cd49ce.tar.gz chat-0031c6fd1a4df621cbecfd2a2b3efe9a40cd49ce.tar.bz2 chat-0031c6fd1a4df621cbecfd2a2b3efe9a40cd49ce.zip |
Merge pull request #2229 from mattermost/plt-1770
PLT-1770 Refactor store listeners out of highly used components
Diffstat (limited to 'web/react/components/posts_view.jsx')
-rw-r--r-- | web/react/components/posts_view.jsx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/web/react/components/posts_view.jsx b/web/react/components/posts_view.jsx index 15810d9cf..3a84b51f0 100644 --- a/web/react/components/posts_view.jsx +++ b/web/react/components/posts_view.jsx @@ -145,6 +145,7 @@ export default class PostsView extends React.Component { const postCtls = []; let previousPostDay = new Date(0); const userId = UserStore.getCurrentId(); + const profiles = this.props.profiles; let renderedLastViewed = false; @@ -228,6 +229,13 @@ export default class PostsView extends React.Component { const shouldHighlight = this.props.postsToHighlight && this.props.postsToHighlight.hasOwnProperty(post.id); + let profile; + if (UserStore.getCurrentId() === post.user_id) { + profile = UserStore.getCurrentUser(); + } else { + profile = profiles[post.user_id]; + } + const postCtl = ( <Post key={keyPrefix + 'postKey'} @@ -242,6 +250,8 @@ export default class PostsView extends React.Component { shouldHighlight={shouldHighlight} onClick={() => EventHelpers.emitPostFocusEvent(post.id)} //eslint-disable-line no-loop-func displayNameType={this.state.displayNameType} + hasProfiles={profiles && Object.keys(profiles).length > 1} + user={profile} /> ); @@ -413,6 +423,9 @@ export default class PostsView extends React.Component { if (this.state.isScrolling !== nextState.isScrolling) { return true; } + if (!Utils.areObjectsEqual(this.props.profiles, nextProps.profiles)) { + return true; + } return false; } @@ -513,6 +526,7 @@ PostsView.defaultProps = { PostsView.propTypes = { isActive: React.PropTypes.bool, postList: React.PropTypes.object, + profiles: React.PropTypes.object, scrollPostId: React.PropTypes.string, scrollType: React.PropTypes.number, postViewScrolled: React.PropTypes.func.isRequired, |