Skip to content
Merged
Changes from all commits
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
21 changes: 20 additions & 1 deletion src/pages/iou/IOUCurrencySelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import KeyboardAvoidingView from '../../components/KeyboardAvoidingView';
import Button from '../../components/Button';
import FixedFooter from '../../components/FixedFooter';
import * as IOU from '../../libs/actions/IOU';
import {withNetwork} from '../../components/OnyxProvider';
import networkPropTypes from '../../components/networkPropTypes';

/**
* IOU Currency selection for selecting currency
Expand Down Expand Up @@ -51,7 +53,11 @@ const propTypes = {
// ISO4217 Code for the currency
ISO4217: PropTypes.string,
})),

/** Information about the network from Onyx */
network: networkPropTypes.isRequired,
...withLocalizePropTypes,

};

const defaultProps = {
Expand Down Expand Up @@ -84,7 +90,15 @@ class IOUCurrencySelection extends Component {
}

componentDidMount() {
PersonalDetails.getCurrencyList();
this.fetchData();
}

componentDidUpdate(prevProps) {
if (!prevProps.network.isOffline || this.props.network.isOffline) {
return;
}

this.fetchData();
}

/**
Expand Down Expand Up @@ -120,6 +134,10 @@ class IOUCurrencySelection extends Component {
return currencyOptions;
}

fetchData() {
PersonalDetails.getCurrencyList();
}

/**
* Function which toggles a currency in the list
*
Expand Down Expand Up @@ -244,4 +262,5 @@ export default compose(
myPersonalDetails: {key: ONYXKEYS.MY_PERSONAL_DETAILS},
iou: {key: ONYXKEYS.IOU},
}),
withNetwork(),
)(IOUCurrencySelection);