mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fix profiles issue with RHS
This commit is contained in:
@@ -145,7 +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;
|
||||
const profiles = this.props.profiles || {};
|
||||
|
||||
let renderedLastViewed = false;
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ export default class RhsThread extends React.Component {
|
||||
render() {
|
||||
const posts = this.state.posts;
|
||||
const selected = this.state.selected;
|
||||
const profiles = this.state.profiles || {};
|
||||
|
||||
if (posts == null || selected == null) {
|
||||
return (
|
||||
@@ -162,7 +163,7 @@ export default class RhsThread extends React.Component {
|
||||
if (UserStore.getCurrentId() === selected.user_id) {
|
||||
profile = UserStore.getCurrentUser();
|
||||
} else {
|
||||
profile = this.state.profiles[selected.user_id];
|
||||
profile = profiles[selected.user_id];
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -187,7 +188,7 @@ export default class RhsThread extends React.Component {
|
||||
if (UserStore.getCurrentId() === selected.user_id) {
|
||||
p = UserStore.getCurrentUser();
|
||||
} else {
|
||||
p = this.state.profiles[selected.user_id];
|
||||
p = profiles[selected.user_id];
|
||||
}
|
||||
return (
|
||||
<Comment
|
||||
|
||||
@@ -40,12 +40,14 @@ export default class SearchResults extends React.Component {
|
||||
this.mounted = false;
|
||||
|
||||
this.onChange = this.onChange.bind(this);
|
||||
this.onUserChange = this.onUserChange.bind(this);
|
||||
this.resize = this.resize.bind(this);
|
||||
this.handleResize = this.handleResize.bind(this);
|
||||
|
||||
const state = getStateFromStores();
|
||||
state.windowWidth = Utils.windowWidth();
|
||||
state.windowHeight = Utils.windowHeight();
|
||||
state.profiles = JSON.parse(JSON.stringify(UserStore.getProfiles()));
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@@ -53,6 +55,7 @@ export default class SearchResults extends React.Component {
|
||||
this.mounted = true;
|
||||
SearchStore.addSearchChangeListener(this.onChange);
|
||||
ChannelStore.addChangeListener(this.onChange);
|
||||
UserStore.addChangeListener(this.onUserChange);
|
||||
this.resize();
|
||||
window.addEventListener('resize', this.handleResize);
|
||||
}
|
||||
@@ -68,6 +71,7 @@ export default class SearchResults extends React.Component {
|
||||
componentWillUnmount() {
|
||||
SearchStore.removeSearchChangeListener(this.onChange);
|
||||
ChannelStore.removeChangeListener(this.onChange);
|
||||
UserStore.removeChangeListener(this.onUserChange);
|
||||
this.mounted = false;
|
||||
window.removeEventListener('resize', this.handleResize);
|
||||
}
|
||||
@@ -85,6 +89,10 @@ export default class SearchResults extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
onUserChange() {
|
||||
this.setState({profiles: JSON.parse(JSON.stringify(UserStore.getProfiles()))});
|
||||
}
|
||||
|
||||
resize() {
|
||||
$('#search-items-container').scrollTop(0);
|
||||
if (this.state.windowWidth > 768) {
|
||||
@@ -101,6 +109,7 @@ export default class SearchResults extends React.Component {
|
||||
}
|
||||
var noResults = (!results || !results.order || !results.order.length);
|
||||
var searchTerm = SearchStore.getSearchTerm();
|
||||
const profiles = this.state.profiles || {};
|
||||
|
||||
var ctls = null;
|
||||
|
||||
@@ -140,6 +149,7 @@ export default class SearchResults extends React.Component {
|
||||
key={post.id}
|
||||
channel={this.state.channels.get(post.channel_id)}
|
||||
post={post}
|
||||
user={profiles[post.user_id]}
|
||||
term={searchTerm}
|
||||
isMentionSearch={this.props.isMentionSearch}
|
||||
/>
|
||||
|
||||
@@ -36,9 +36,10 @@ export default class SearchResultsItem extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
var channelName = null;
|
||||
let channelName = null;
|
||||
const channel = this.props.channel;
|
||||
var timestamp = UserStore.getCurrentUser().update_at;
|
||||
const timestamp = UserStore.getCurrentUser().update_at;
|
||||
const user = this.props.user || {};
|
||||
|
||||
if (channel) {
|
||||
channelName = channel.display_name;
|
||||
@@ -84,7 +85,7 @@ export default class SearchResultsItem extends React.Component {
|
||||
</div>
|
||||
<div>
|
||||
<ul className='post__header'>
|
||||
<li className='col__name'><strong><UserProfile userId={this.props.post.user_id}/></strong></li>
|
||||
<li className='col__name'><strong><UserProfile user={user}/></strong></li>
|
||||
<li className='col'>
|
||||
<time className='search-item-time'>
|
||||
<FormattedDate
|
||||
@@ -135,6 +136,7 @@ export default class SearchResultsItem extends React.Component {
|
||||
|
||||
SearchResultsItem.propTypes = {
|
||||
post: React.PropTypes.object,
|
||||
user: React.PropTypes.object,
|
||||
channel: React.PropTypes.object,
|
||||
isMentionSearch: React.PropTypes.bool,
|
||||
term: React.PropTypes.string
|
||||
|
||||
Reference in New Issue
Block a user