Skip to content

Commit

Permalink
Fix regression when scrolling in search screen (#2339)
Browse files Browse the repository at this point in the history
  • Loading branch information
enahum committed Nov 14, 2018
1 parent c1b2667 commit 8a7dabf
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions app/screens/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ export default class Search extends PureComponent {

componentDidUpdate(prevProps) {
const {searchingStatus: status, recent, enableDateSuggestion} = this.props;
const shouldScroll = status === RequestStatus.SUCCESS &&
!this.props.isSearchGettingMore &&
!prevProps.isSearchGettingMore;
const {searchingStatus: prevStatus} = prevProps;
const shouldScroll = prevStatus !== status &&
(status === RequestStatus.SUCCESS || status === RequestStatus.STARTED) &&
!this.props.isSearchGettingMore && !prevProps.isSearchGettingMore;

if (this.props.isLandscape !== prevProps.isLandscape) {
this.refs.searchBar.blur();
Expand Down Expand Up @@ -702,17 +703,21 @@ export default class Search extends PureComponent {
}
break;
case RequestStatus.FAILURE:
results = [{
id: RequestStatus.FAILURE,
component: (
<View style={style.searching}>
<PostListRetry
retry={this.retry}
theme={theme}
/>
</View>
),
}];
if (postIds.length) {
results = postIds;
} else {
results = [{
id: RequestStatus.FAILURE,
component: (
<View style={style.searching}>
<PostListRetry
retry={this.retry}
theme={theme}
/>
</View>
),
}];
}
break;
}

Expand Down

0 comments on commit 8a7dabf

Please sign in to comment.