diff options
Diffstat (limited to 'webapp/components/post_view')
4 files changed, 60 insertions, 7 deletions
diff --git a/webapp/components/post_view/components/post.jsx b/webapp/components/post_view/components/post.jsx index b372d2548..1b94f717d 100644 --- a/webapp/components/post_view/components/post.jsx +++ b/webapp/components/post_view/components/post.jsx @@ -3,6 +3,7 @@ import PostHeader from './post_header.jsx'; import PostBody from './post_body.jsx'; +import ProfilePicture from 'components/profile_picture.jsx'; import Constants from 'utils/constants.jsx'; const ActionTypes = Constants.ActionTypes; @@ -105,11 +106,11 @@ export default class Post extends React.Component { return true; } - if (!Utils.areObjectsEqual(nextProps.user, this.props.user)) { + if (nextProps.status !== this.props.status) { return true; } - if (nextProps.emojis !== this.props.emojis) { + if (!Utils.areObjectsEqual(nextProps.user, this.props.user)) { return true; } @@ -192,10 +193,9 @@ export default class Post extends React.Component { } let profilePic = ( - <img + <ProfilePicture src={PostUtils.getProfilePicSrcForPost(post, timestamp)} - height='36' - width='36' + status={this.props.status} /> ); @@ -288,5 +288,6 @@ Post.propTypes = { isCommentMention: React.PropTypes.bool, useMilitaryTime: React.PropTypes.bool.isRequired, emojis: React.PropTypes.object.isRequired, - isFlagged: React.PropTypes.bool + isFlagged: React.PropTypes.bool, + status: React.PropTypes.string }; diff --git a/webapp/components/post_view/components/post_list.jsx b/webapp/components/post_view/components/post_list.jsx index 95b30a9d7..a1fd7a317 100644 --- a/webapp/components/post_view/components/post_list.jsx +++ b/webapp/components/post_view/components/post_list.jsx @@ -289,6 +289,11 @@ export default class PostList extends React.Component { isFlagged = this.props.flaggedPosts.get(post.id) === 'true'; } + let status = ''; + if (this.props.statuses) { + status = this.props.statuses[profile.id] || 'offline'; + } + const postCtl = ( <Post key={keyPrefix + 'postKey'} @@ -311,6 +316,7 @@ export default class PostList extends React.Component { useMilitaryTime={this.props.useMilitaryTime} emojis={this.props.emojis} isFlagged={isFlagged} + status={status} /> ); @@ -579,5 +585,6 @@ PostList.propTypes = { useMilitaryTime: React.PropTypes.bool.isRequired, isFocusPost: React.PropTypes.bool, emojis: React.PropTypes.object.isRequired, - flaggedPosts: React.PropTypes.object + flaggedPosts: React.PropTypes.object, + statuses: React.PropTypes.object }; diff --git a/webapp/components/post_view/post_focus_view_controller.jsx b/webapp/components/post_view/post_focus_view_controller.jsx index a1c474184..7903087e9 100644 --- a/webapp/components/post_view/post_focus_view_controller.jsx +++ b/webapp/components/post_view/post_focus_view_controller.jsx @@ -23,6 +23,7 @@ export default class PostFocusView extends React.Component { this.onPostsChange = this.onPostsChange.bind(this); this.onUserChange = this.onUserChange.bind(this); this.onEmojiChange = this.onEmojiChange.bind(this); + this.onStatusChange = this.onStatusChange.bind(this); this.onPreferenceChange = this.onPreferenceChange.bind(this); this.onPostListScroll = this.onPostListScroll.bind(this); @@ -36,10 +37,16 @@ export default class PostFocusView extends React.Component { const joinLeaveEnabled = PreferenceStore.getBool(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, 'join_leave', true); + let statuses; + if (channel && channel.type !== Constants.DM_CHANNEL) { + statuses = Object.assign({}, UserStore.getStatuses()); + } + this.state = { postList: PostStore.filterPosts(focusedPostId, joinLeaveEnabled), currentUser: UserStore.getCurrentUser(), profiles, + statuses, scrollType: ScrollTypes.POST, currentChannel: ChannelStore.getCurrentId().slice(), scrollPostId: focusedPostId, @@ -54,6 +61,7 @@ export default class PostFocusView extends React.Component { ChannelStore.addChangeListener(this.onChannelChange); PostStore.addChangeListener(this.onPostsChange); UserStore.addChangeListener(this.onUserChange); + UserStore.addStatusesChangeListener(this.onStatusChange); EmojiStore.addChangeListener(this.onEmojiChange); PreferenceStore.addChangeListener(this.onPreferenceChange); } @@ -62,7 +70,9 @@ export default class PostFocusView extends React.Component { ChannelStore.removeChangeListener(this.onChannelChange); PostStore.removeChangeListener(this.onPostsChange); UserStore.removeChangeListener(this.onUserChange); + UserStore.removeStatusesChangeListener(this.onStatusChange); EmojiStore.removeChangeListener(this.onEmojiChange); + PreferenceStore.removeChangeListener(this.onPreferenceChange); } onChannelChange() { @@ -100,6 +110,16 @@ export default class PostFocusView extends React.Component { this.setState({currentUser: UserStore.getCurrentUser(), profiles: JSON.parse(JSON.stringify(profiles))}); } + onStatusChange() { + const channel = ChannelStore.getCurrent(); + let statuses; + if (channel && channel.type !== Constants.DM_CHANNEL) { + statuses = Object.assign({}, UserStore.getStatuses()); + } + + this.setState({statuses}); + } + onEmojiChange() { this.setState({ emojis: EmojiStore.getEmojis() @@ -151,6 +171,7 @@ export default class PostFocusView extends React.Component { isFocusPost={true} emojis={this.state.emojis} flaggedPosts={this.state.flaggedPosts} + statuses={this.state.statuses} /> ); } diff --git a/webapp/components/post_view/post_view_controller.jsx b/webapp/components/post_view/post_view_controller.jsx index 2451dfc8d..7e30818fb 100644 --- a/webapp/components/post_view/post_view_controller.jsx +++ b/webapp/components/post_view/post_view_controller.jsx @@ -26,6 +26,7 @@ export default class PostViewController extends React.Component { this.onUserChange = this.onUserChange.bind(this); this.onPostsChange = this.onPostsChange.bind(this); this.onEmojisChange = this.onEmojisChange.bind(this); + this.onStatusChange = this.onStatusChange.bind(this); this.onPostsViewJumpRequest = this.onPostsViewJumpRequest.bind(this); this.onSetNewMessageIndicator = this.onSetNewMessageIndicator.bind(this); this.onPostListScroll = this.onPostListScroll.bind(this); @@ -46,11 +47,17 @@ export default class PostViewController extends React.Component { const joinLeaveEnabled = PreferenceStore.getBool(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, 'join_leave', true); + let statuses; + if (channel && channel.type !== Constants.DM_CHANNEL) { + statuses = Object.assign({}, UserStore.getStatuses()); + } + this.state = { channel, postList: PostStore.filterPosts(channel.id, joinLeaveEnabled), currentUser: UserStore.getCurrentUser(), profiles, + statuses, atTop: PostStore.getVisibilityAtTop(channel.id), lastViewed, ownNewMessage: false, @@ -122,9 +129,20 @@ export default class PostViewController extends React.Component { }); } + onStatusChange() { + const channel = this.state.channel; + let statuses; + if (channel && channel.type !== Constants.DM_CHANNEL) { + statuses = Object.assign({}, UserStore.getStatuses()); + } + + this.setState({statuses}); + } + onActivate() { PreferenceStore.addChangeListener(this.onPreferenceChange); UserStore.addChangeListener(this.onUserChange); + UserStore.addStatusesChangeListener(this.onStatusChange); PostStore.addChangeListener(this.onPostsChange); PostStore.addPostsViewJumpListener(this.onPostsViewJumpRequest); EmojiStore.addChangeListener(this.onEmojisChange); @@ -134,6 +152,7 @@ export default class PostViewController extends React.Component { onDeactivate() { PreferenceStore.removeChangeListener(this.onPreferenceChange); UserStore.removeChangeListener(this.onUserChange); + UserStore.removeStatusesChangeListener(this.onStatusChange); PostStore.removeChangeListener(this.onPostsChange); PostStore.removePostsViewJumpListener(this.onPostsViewJumpRequest); EmojiStore.removeChangeListener(this.onEmojisChange); @@ -267,6 +286,10 @@ export default class PostViewController extends React.Component { return true; } + if (!Utils.areObjectsEqual(nextState.statuses, this.state.statuses)) { + return true; + } + if (!Utils.areObjectsEqual(nextState.postList, this.state.postList)) { return true; } @@ -311,6 +334,7 @@ export default class PostViewController extends React.Component { lastViewed={this.state.lastViewed} emojis={this.state.emojis} ownNewMessage={this.state.ownNewMessage} + statuses={this.state.statuses} /> ); } |