Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SearchPage update headerMessage in debounce.updateOptions #17643

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 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,7 +135,13 @@ class SearchPage extends Component {
this.state.searchValue.trim(),
this.props.betas,
);
const headerMessage = OptionsListUtils.getHeaderMessage(
(recentReports.length + personalDetails.length) !== 0,
Boolean(userToInvite),
this.state.searchValue,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hellohublot we have a lint error here, maybe you can update code like this

        this.setState((prevState) => {
            const headerMessage = OptionsListUtils.getHeaderMessage(
                (recentReports.length + personalDetails.length) !== 0,
                Boolean(userToInvite),
                prevState.searchValue,
            );
            return ({
                headerMessage,
                userToInvite,
                recentReports,
                personalDetails,
            });
        });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fedirjh Thanks a lot, got it, I was wondering, I can access searchValue.trim but not searchValue, I was going to ignore this eslint check, thanks a lot for your help, I have modified to your solution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good!

);
this.setState({
headerMessage,
userToInvite,
recentReports,
personalDetails,
Expand Down Expand Up @@ -164,11 +171,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 +185,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