From ab72afdeabf0f93bc0bb9e4e9a124114b6baaac1 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Wed, 24 Feb 2016 07:59:33 -0500
Subject: Fix profiles issue with RHS

---
 web/react/components/search_results.jsx | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'web/react/components/search_results.jsx')

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}
                     />
-- 
cgit v1.2.3-1-g7c22

