Skip to content

Commit

Permalink
Merge pull request #13412 from Expensify/tgolen-fix-currency-selector
Browse files Browse the repository at this point in the history
(cherry picked from commit c9de2b4)
  • Loading branch information
francoisl authored and OSBotify committed Dec 7, 2022
1 parent dfd8eff commit 69b382e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
18 changes: 0 additions & 18 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,23 +779,6 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma
return '';
}

/**
* Returns the currency list for sections display
*
* @param {Object} currencyOptions
* @param {String} searchValue
* @returns {Array}
*/
function getCurrencyListForSections(currencyOptions, searchValue) {
const filteredOptions = _.filter(currencyOptions, currencyOption => (
isSearchStringMatch(searchValue, currencyOption.text)));

return {
// returns filtered options i.e. options with string match if search text is entered
currencyOptions: filteredOptions,
};
}

export {
addSMSDomainIfPhoneNumber,
isCurrentUser,
Expand All @@ -804,7 +787,6 @@ export {
getMemberInviteOptions,
getHeaderMessage,
getPersonalDetailsForLogins,
getCurrencyListForSections,
getIOUConfirmationOptionsFromMyPersonalDetail,
getIOUConfirmationOptionsFromParticipants,
getSearchText,
Expand Down
15 changes: 6 additions & 9 deletions src/pages/iou/IOUCurrencySelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import ONYXKEYS from '../../ONYXKEYS';
import * as OptionsListUtils from '../../libs/OptionsListUtils';
import OptionsSelector from '../../components/OptionsSelector';
import Navigation from '../../libs/Navigation/Navigation';
import ScreenWrapper from '../../components/ScreenWrapper';
Expand Down Expand Up @@ -41,11 +40,9 @@ class IOUCurrencySelection extends Component {
constructor(props) {
super(props);

const {currencyOptions} = OptionsListUtils.getCurrencyListForSections(this.getCurrencyOptions(this.props.currencyList), '');

this.state = {
searchValue: '',
currencyData: currencyOptions,
currencyData: this.getCurrencyOptions(this.props.currencyList),
};
this.getCurrencyOptions = this.getCurrencyOptions.bind(this);
this.getSections = this.getSections.bind(this);
Expand Down Expand Up @@ -90,13 +87,13 @@ class IOUCurrencySelection extends Component {
* @return {void}
*/
changeSearchValue(searchValue) {
const {currencyOptions} = OptionsListUtils.getCurrencyListForSections(
this.getCurrencyOptions(this.props.currencyList),
searchValue,
);
const currencyOptions = this.getCurrencyOptions(this.props.currencyList);
const searchRegex = new RegExp(searchValue, 'i');
const filteredCurrencies = _.filter(currencyOptions, currencyOption => searchRegex.test(currencyOption.text));

this.setState({
searchValue,
currencyData: currencyOptions,
currencyData: filteredCurrencies,
});
}

Expand Down

0 comments on commit 69b382e

Please sign in to comment.