summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-02-24 08:10:55 -0500
committerChristopher Speller <crspeller@gmail.com>2016-02-24 08:10:55 -0500
commit940b706ac8a790db9f089e000489d89426915fc9 (patch)
tree87ef0bccd65578d1867a6a330ae38a87910fd54a
parent52767d9dcdc84fca4cd7a5b5c7ece2650691b91d (diff)
parentab72afdeabf0f93bc0bb9e4e9a124114b6baaac1 (diff)
downloadchat-940b706ac8a790db9f089e000489d89426915fc9.tar.gz
chat-940b706ac8a790db9f089e000489d89426915fc9.tar.bz2
chat-940b706ac8a790db9f089e000489d89426915fc9.zip
Merge pull request #2239 from mattermost/rhs-fix
Fix profiles issue with RHS
-rw-r--r--web/react/components/posts_view.jsx2
-rw-r--r--web/react/components/rhs_thread.jsx5
-rw-r--r--web/react/components/search_results.jsx10
-rw-r--r--web/react/components/search_results_item.jsx8
4 files changed, 19 insertions, 6 deletions
diff --git a/web/react/components/posts_view.jsx b/web/react/components/posts_view.jsx
index 3a84b51f0..1ea7711ea 100644
--- a/web/react/components/posts_view.jsx
+++ b/web/react/components/posts_view.jsx
@@ -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;
diff --git a/web/react/components/rhs_thread.jsx b/web/react/components/rhs_thread.jsx
index 975a39171..d007dd47f 100644
--- a/web/react/components/rhs_thread.jsx
+++ b/web/react/components/rhs_thread.jsx
@@ -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
diff --git a/web/react/components/search_results.jsx b/web/react/components/search_results.jsx
index d10c5be27..55ece2c97 100644
--- a/web/react/components/search_results.jsx
+++ b/web/react/components/search_results.jsx
@@ -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}
/>
diff --git a/web/react/components/search_results_item.jsx b/web/react/components/search_results_item.jsx
index 3363c97f7..05292b7b3 100644
--- a/web/react/components/search_results_item.jsx
+++ b/web/react/components/search_results_item.jsx
@@ -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