Skip to content

Commit

Permalink
Merge pull request #17643 from hellohublot/Fix_SearchPage_HeaderMessage
Browse files Browse the repository at this point in the history
Fix SearchPage update headerMessage in debounce.updateOptions
  • Loading branch information
chiragsalian authored Apr 19, 2023
2 parents 541a5ef + e59e2d0 commit 5cd0ab3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/pages/SearchPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class SearchPage extends Component {

this.state = {
searchValue: '',
headerMessage: '',
recentReports,
personalDetails,
userToInvite,
Expand Down Expand Up @@ -134,10 +135,18 @@ class SearchPage extends Component {
this.state.searchValue.trim(),
this.props.betas,
);
this.setState({
userToInvite,
recentReports,
personalDetails,
this.setState((prevState) => {
const headerMessage = OptionsListUtils.getHeaderMessage(
(recentReports.length + personalDetails.length) !== 0,
Boolean(userToInvite),
prevState.searchValue,
);
return ({
headerMessage,
userToInvite,
recentReports,
personalDetails,
});
});
}

Expand All @@ -164,11 +173,6 @@ class SearchPage extends Component {

render() {
const sections = this.getSections();
const headerMessage = OptionsListUtils.getHeaderMessage(
(this.state.recentReports.length + this.state.personalDetails.length) !== 0,
Boolean(this.state.userToInvite),
this.state.searchValue,
);
return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => (
Expand All @@ -183,7 +187,7 @@ class SearchPage extends Component {
value={this.state.searchValue}
onSelectRow={this.selectReport}
onChangeText={this.onChangeText}
headerMessage={headerMessage}
headerMessage={this.state.headerMessage}
hideSectionHeaders
showTitleTooltip
shouldShowOptions={didScreenTransitionEnd}
Expand Down

0 comments on commit 5cd0ab3

Please sign in to comment.