Skip to content

Commit

Permalink
Merge pull request #1976 from myxmaster/sort-currencies
Browse files Browse the repository at this point in the history
Display currencies sorted
  • Loading branch information
kaloudis authored Feb 22, 2024
2 parents 72f4256 + 1bbac70 commit dc7bb91
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions views/Settings/SelectCurrency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ export default class SelectCurrency extends React.Component<
);

updateSearch = (value: string) => {
const result = CURRENCY_KEYS.filter(
(item: any) =>
item.key.includes(value) ||
item.key.toLowerCase().includes(value)
const result = CURRENCY_KEYS.filter((item: any) =>
item.key.toLowerCase().includes(value.toLowerCase())
);
this.setState({
search: value,
Expand All @@ -74,8 +72,15 @@ export default class SelectCurrency extends React.Component<

render() {
const { navigation, SettingsStore } = this.props;
const { selectedCurrency, search, currencies, fiatRatesSource } =
this.state;
const { selectedCurrency, search, fiatRatesSource } = this.state;
const currencies = this.state.currencies
.sort((a, b) =>
a.key
.substring(a.key.indexOf(' ') + 1)
.localeCompare(b.key.substring(b.key.indexOf(' ') + 1))
)
.filter((c) => c.supportedSources?.includes(fiatRatesSource));

const { updateSettings, getSettings }: any = SettingsStore;

return (
Expand Down Expand Up @@ -118,9 +123,7 @@ export default class SelectCurrency extends React.Component<
}}
/>
<FlatList
data={currencies.filter((c) =>
c.supportedSources?.includes(fiatRatesSource)
)}
data={currencies}
renderItem={({ item }) => (
<ListItem
containerStyle={{
Expand Down

0 comments on commit dc7bb91

Please sign in to comment.