From 91980c75cdade359d14756d5a4b99c81a9c237bd Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Wed, 4 May 2022 12:42:22 +0000 Subject: [PATCH] refetch actions for IOUModal.js --- src/pages/iou/IOUModal.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index a75b7f990cfe..9c6640dc2378 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -26,6 +26,8 @@ import CONST from '../../CONST'; import KeyboardAvoidingView from '../../components/KeyboardAvoidingView'; import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import ROUTES from '../../ROUTES'; +import networkPropTypes from '../../components/networkPropTypes'; +import {withNetwork} from '../../components/OnyxProvider'; /** * IOU modal for requesting money and splitting bills. @@ -50,6 +52,9 @@ const propTypes = { localCurrencyCode: PropTypes.string, }), + /** Information about the network */ + network: networkPropTypes.isRequired, + // Holds data related to IOU view state, rather than the underlying IOU data. iou: PropTypes.shape({ /** Whether or not transaction creation has started */ @@ -138,11 +143,15 @@ class IOUModal extends Component { } componentDidMount() { - PersonalDetails.fetchLocalCurrency(); + this.fetchData(); IOU.setIOUSelectedCurrency(this.props.myPersonalDetails.localCurrencyCode); } componentDidUpdate(prevProps) { + if (prevProps.network.isOffline && !this.props.network.isOffline) { + this.fetchData(); + } + // Successfully close the modal if transaction creation has ended and there is no error if (prevProps.iou.creatingIOUTransaction && !this.props.iou.creatingIOUTransaction && !this.props.iou.error) { Navigation.dismissModal(); @@ -215,6 +224,10 @@ class IOUModal extends Component { return this.props.translate(this.steps[currentStepIndex]) || ''; } + fetchData() { + PersonalDetails.fetchLocalCurrency(); + } + /** * Update comment whenever user enters any new text * @@ -453,6 +466,7 @@ IOUModal.defaultProps = defaultProps; export default compose( withLocalize, + withNetwork(), withOnyx({ report: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID', '')}`,