From 8a072cf69ef75746ac10fc107d973143ce6c9edc Mon Sep 17 00:00:00 2001 From: OSBotify Date: Mon, 18 Sep 2023 02:13:16 +0000 Subject: [PATCH 1/3] Update version to 1.3.70-6 (cherry picked from commit 48dc5c05f7cd1eeac81c108fe3bde6e687e36ca5) --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index d9eb60471773..58dcbf444e20 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -90,8 +90,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001037005 - versionName "1.3.70-5" + versionCode 1001037006 + versionName "1.3.70-6" } flavorDimensions "default" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 440e48e0c83d..9290498c08a0 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ CFBundleVersion - 1.3.70.5 + 1.3.70.6 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 9d7fc804acd9..ed191861e3ca 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.3.70.5 + 1.3.70.6 diff --git a/package-lock.json b/package-lock.json index ae8ecdcb626f..3d6b0369395c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.3.70-5", + "version": "1.3.70-6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.3.70-5", + "version": "1.3.70-6", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index b0dfa9fe8ade..71ab3f0889ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.3.70-5", + "version": "1.3.70-6", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From 3c00f808ce0bb55ab983e5a7aab7b600874e4011 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Mon, 18 Sep 2023 09:51:09 +0800 Subject: [PATCH 2/3] Merge pull request #27476 from Expensify/revert-23076-fix/16251-SearchPage-refactoring Revert "Convert SearchPage to functional component" (cherry picked from commit 78769290a10e9cfb0ee80ab852d7f39930050be1) --- src/pages/SearchPage.js | 201 +++++++++++++++++++++++++--------------- 1 file changed, 128 insertions(+), 73 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index dd42ed80c3d4..52ed2cb8edd7 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -1,5 +1,5 @@ import _ from 'underscore'; -import React, {useCallback, useEffect, useState, useMemo} from 'react'; +import React, {Component} from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; @@ -9,15 +9,17 @@ import * as ReportUtils from '../libs/ReportUtils'; import ONYXKEYS from '../ONYXKEYS'; import styles from '../styles/styles'; import Navigation from '../libs/Navigation/Navigation'; +import withWindowDimensions, {windowDimensionsPropTypes} from '../components/withWindowDimensions'; import * as Report from '../libs/actions/Report'; import HeaderWithBackButton from '../components/HeaderWithBackButton'; import ScreenWrapper from '../components/ScreenWrapper'; import Timing from '../libs/actions/Timing'; import CONST from '../CONST'; +import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; +import compose from '../libs/compose'; import personalDetailsPropType from './personalDetailsPropType'; import reportPropTypes from './reportPropTypes'; import Performance from '../libs/Performance'; -import useLocalize from '../hooks/useLocalize'; const propTypes = { /* Onyx Props */ @@ -30,6 +32,11 @@ const propTypes = { /** All reports shared with the user */ reports: PropTypes.objectOf(reportPropTypes), + + /** Window Dimensions Props */ + ...windowDimensionsPropTypes, + + ...withLocalizePropTypes, }; const defaultProps = { @@ -38,114 +45,121 @@ const defaultProps = { reports: {}, }; -function SearchPage({betas, personalDetails, reports}) { - // Data for initialization (runs only on the first render) - const { - recentReports: initialRecentReports, - personalDetails: initialPersonalDetails, - userToInvite: initialUserToInvite, - // Ignoring the rule because in this case we need the data only initially - // eslint-disable-next-line react-hooks/exhaustive-deps - } = useMemo(() => OptionsListUtils.getSearchOptions(reports, personalDetails, '', betas), []); - - const [searchValue, setSearchValue] = useState(''); - const [searchOptions, setSearchOptions] = useState({ - recentReports: initialRecentReports, - personalDetails: initialPersonalDetails, - userToInvite: initialUserToInvite, - }); - - const {translate} = useLocalize(); - - const updateOptions = useCallback(() => { - const { - recentReports: localRecentReports, - personalDetails: localPersonalDetails, - userToInvite: localUserToInvite, - } = OptionsListUtils.getSearchOptions(reports, personalDetails, searchValue.trim(), betas); - - setSearchOptions({ - recentReports: localRecentReports, - personalDetails: localPersonalDetails, - userToInvite: localUserToInvite, - }); - }, [reports, personalDetails, searchValue, betas]); - - const debouncedUpdateOptions = useMemo(() => _.debounce(updateOptions, 75), [updateOptions]); +class SearchPage extends Component { + constructor(props) { + super(props); - useEffect(() => { Timing.start(CONST.TIMING.SEARCH_RENDER); Performance.markStart(CONST.TIMING.SEARCH_RENDER); - }, []); - useEffect(() => { - debouncedUpdateOptions(); - }, [searchValue, debouncedUpdateOptions]); + this.searchRendered = this.searchRendered.bind(this); + this.selectReport = this.selectReport.bind(this); + this.onChangeText = this.onChangeText.bind(this); + this.debouncedUpdateOptions = _.debounce(this.updateOptions.bind(this), 75); + + const {recentReports, personalDetails, userToInvite} = OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, '', props.betas); + + this.state = { + searchValue: '', + recentReports, + personalDetails, + userToInvite, + }; + } + + componentDidUpdate(prevProps) { + if (_.isEqual(prevProps.reports, this.props.reports) && _.isEqual(prevProps.personalDetails, this.props.personalDetails)) { + return; + } + this.updateOptions(); + } + + onChangeText(searchValue = '') { + this.setState({searchValue}, this.debouncedUpdateOptions); + } /** * Returns the sections needed for the OptionsSelector * * @returns {Array} */ - const getSections = () => { + getSections() { const sections = []; let indexOffset = 0; - if (searchOptions.recentReports.length > 0) { + if (this.state.recentReports.length > 0) { sections.push({ - data: searchOptions.recentReports, + data: this.state.recentReports, shouldShow: true, indexOffset, }); - indexOffset += searchOptions.recentReports.length; + indexOffset += this.state.recentReports.length; } - if (searchOptions.personalDetails.length > 0) { + if (this.state.personalDetails.length > 0) { sections.push({ - data: searchOptions.personalDetails, + data: this.state.personalDetails, shouldShow: true, indexOffset, }); - indexOffset += searchOptions.recentReports.length; + indexOffset += this.state.recentReports.length; } - if (searchOptions.userToInvite) { + if (this.state.userToInvite) { sections.push({ - data: [searchOptions.userToInvite], + data: [this.state.userToInvite], shouldShow: true, indexOffset, }); } return sections; - }; + } - const searchRendered = () => { + searchRendered() { Timing.end(CONST.TIMING.SEARCH_RENDER); Performance.markEnd(CONST.TIMING.SEARCH_RENDER); - }; - - const onChangeText = (value = '') => { - setSearchValue(value); - }; + } + + updateOptions() { + const {recentReports, personalDetails, userToInvite} = OptionsListUtils.getSearchOptions( + this.props.reports, + this.props.personalDetails, + this.state.searchValue.trim(), + this.props.betas, + ); + this.setState({ + userToInvite, + recentReports, + personalDetails, + }); + } /** * Reset the search value and redirect to the selected report * * @param {Object} option */ - const selectReport = (option) => { + selectReport(option) { if (!option) { return; } + if (option.reportID) { - setSearchValue(''); - Navigation.dismissModal(option.reportID); + this.setState( + { + searchValue: '', + }, + () => { + Navigation.dismissModal(option.reportID); + }, + ); } else { Report.navigateToAndOpenReport([option.login]); } - }; + } +<<<<<<< HEAD const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); const headerMessage = OptionsListUtils.getHeaderMessage( searchOptions.recentReports.length + searchOptions.personalDetails.length !== 0, @@ -176,19 +190,60 @@ function SearchPage({betas, personalDetails, reports}) { )} ); +======= + render() { + const sections = this.getSections(); + const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(this.props.personalDetails); + const headerMessage = OptionsListUtils.getHeaderMessage( + this.state.recentReports.length + this.state.personalDetails.length !== 0, + Boolean(this.state.userToInvite), + this.state.searchValue, + ); + + return ( + + {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( + <> + + + + + + )} + + ); + } +>>>>>>> 7876929 (Merge pull request #27476 from Expensify/revert-23076-fix/16251-SearchPage-refactoring) } SearchPage.propTypes = propTypes; SearchPage.defaultProps = defaultProps; -SearchPage.displayName = 'SearchPage'; -export default withOnyx({ - reports: { - key: ONYXKEYS.COLLECTION.REPORT, - }, - personalDetails: { - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - }, - betas: { - key: ONYXKEYS.BETAS, - }, -})(SearchPage); + +export default compose( + withLocalize, + withWindowDimensions, + withOnyx({ + reports: { + key: ONYXKEYS.COLLECTION.REPORT, + }, + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + betas: { + key: ONYXKEYS.BETAS, + }, + }), +)(SearchPage); From 68bbc2758d440639892b32b24cb2335346d1574a Mon Sep 17 00:00:00 2001 From: Amy Evans Date: Mon, 18 Sep 2023 10:31:00 +0800 Subject: [PATCH 3/3] Resolve merge conflict --- src/pages/SearchPage.js | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 52ed2cb8edd7..6505b604b614 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -159,38 +159,6 @@ class SearchPage extends Component { } } -<<<<<<< HEAD - const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); - const headerMessage = OptionsListUtils.getHeaderMessage( - searchOptions.recentReports.length + searchOptions.personalDetails.length !== 0, - Boolean(searchOptions.userToInvite), - searchValue, - ); - return ( - - {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( - <> - - - - - - )} - - ); -======= render() { const sections = this.getSections(); const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(this.props.personalDetails); @@ -218,7 +186,6 @@ class SearchPage extends Component { textInputLabel={this.props.translate('optionsSelector.nameEmailOrPhoneNumber')} onLayout={this.searchRendered} safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle} - autoFocus /> @@ -226,7 +193,6 @@ class SearchPage extends Component { ); } ->>>>>>> 7876929 (Merge pull request #27476 from Expensify/revert-23076-fix/16251-SearchPage-refactoring) } SearchPage.propTypes = propTypes;