summaryrefslogtreecommitdiffstats
path: root/web/react
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-02-25 19:02:30 -0500
committerJoramWilander <jwawilander@gmail.com>2016-02-25 19:02:30 -0500
commitd563bf11527698bef02fc4b17852e260ba43f4e8 (patch)
treee90efc97f128418b2113331e57ec2ae56f328b04 /web/react
parent7e59440abbcbfd960a0e5aa6e0b2bb6f91389877 (diff)
downloadchat-d563bf11527698bef02fc4b17852e260ba43f4e8.tar.gz
chat-d563bf11527698bef02fc4b17852e260ba43f4e8.tar.bz2
chat-d563bf11527698bef02fc4b17852e260ba43f4e8.zip
Update search results profiles properly on refresh and handle scrollHeight error
Diffstat (limited to 'web/react')
-rw-r--r--web/react/components/posts_view.jsx2
-rw-r--r--web/react/components/search_results.jsx20
2 files changed, 18 insertions, 4 deletions
diff --git a/web/react/components/posts_view.jsx b/web/react/components/posts_view.jsx
index 1ea7711ea..9a1673483 100644
--- a/web/react/components/posts_view.jsx
+++ b/web/react/components/posts_view.jsx
@@ -321,7 +321,7 @@ export default class PostsView extends React.Component {
if (this.refs.newMessageSeparator) {
var objDiv = this.refs.postlist;
objDiv.scrollTop = this.refs.newMessageSeparator.offsetTop; //scrolls node to top of Div
- } else {
+ } else if (this.refs.postlist) {
this.refs.postlist.scrollTop = this.refs.postlist.scrollHeight;
}
});
diff --git a/web/react/components/search_results.jsx b/web/react/components/search_results.jsx
index 55ece2c97..8985063a0 100644
--- a/web/react/components/search_results.jsx
+++ b/web/react/components/search_results.jsx
@@ -61,7 +61,15 @@ export default class SearchResults extends React.Component {
}
shouldComponentUpdate(nextProps, nextState) {
- return !Utils.areObjectsEqual(this.props, nextProps) || !Utils.areObjectsEqual(this.state, nextState);
+ if (!Utils.areObjectsEqual(this.props, nextProps)) {
+ return true;
+ }
+
+ if (!Utils.areObjectsEqual(this.state, nextState)) {
+ return true;
+ }
+
+ return false;
}
componentDidUpdate() {
@@ -143,13 +151,19 @@ export default class SearchResults extends React.Component {
);
} else {
ctls = results.order.map(function mymap(id) {
- var post = results.posts[id];
+ const post = results.posts[id];
+ let profile;
+ if (UserStore.getCurrentId() === post.user_id) {
+ profile = UserStore.getCurrentUser();
+ } else {
+ profile = profiles[post.user_id];
+ }
return (
<SearchResultsItem
key={post.id}
channel={this.state.channels.get(post.channel_id)}
post={post}
- user={profiles[post.user_id]}
+ user={profile}
term={searchTerm}
isMentionSearch={this.props.isMentionSearch}
/>