Update search results profiles properly on refresh and handle scrollHeight error

Этот коммит содержится в:
JoramWilander
2016-02-25 19:02:30 -05:00
родитель 7e59440abb
Коммит d563bf1152
2 изменённых файлов: 18 добавлений и 4 удалений

Просмотреть файл

@@ -321,7 +321,7 @@ export default class PostsView extends React.Component {
if (this.refs.newMessageSeparator) { if (this.refs.newMessageSeparator) {
var objDiv = this.refs.postlist; var objDiv = this.refs.postlist;
objDiv.scrollTop = this.refs.newMessageSeparator.offsetTop; //scrolls node to top of Div 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; this.refs.postlist.scrollTop = this.refs.postlist.scrollHeight;
} }
}); });

Просмотреть файл

@@ -61,7 +61,15 @@ export default class SearchResults extends React.Component {
} }
shouldComponentUpdate(nextProps, nextState) { 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() { componentDidUpdate() {
@@ -143,13 +151,19 @@ export default class SearchResults extends React.Component {
); );
} else { } else {
ctls = results.order.map(function mymap(id) { 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 ( return (
<SearchResultsItem <SearchResultsItem
key={post.id} key={post.id}
channel={this.state.channels.get(post.channel_id)} channel={this.state.channels.get(post.channel_id)}
post={post} post={post}
user={profiles[post.user_id]} user={profile}
term={searchTerm} term={searchTerm}
isMentionSearch={this.props.isMentionSearch} isMentionSearch={this.props.isMentionSearch}
/> />