diff --git a/src/Expensify.js b/src/Expensify.js index 431db2e8d9a1..7ae31f43d9d5 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -29,7 +29,9 @@ Onyx.init({ [ONYXKEYS.SESSION]: {loading: false, shouldShowComposeInput: true}, [ONYXKEYS.ACCOUNT]: CONST.DEFAULT_ACCOUNT_DATA, [ONYXKEYS.NETWORK]: {isOffline: false}, - [ONYXKEYS.IOU]: {loading: false, error: false, creatingIOUTransaction: false}, + [ONYXKEYS.IOU]: { + loading: false, error: false, creatingIOUTransaction: false, isRetrievingCurrency: false, + }, }, registerStorageEventListener: (onStorageEvent) => { listenToStorageEvents(onStorageEvent); diff --git a/src/libs/actions/PersonalDetails.js b/src/libs/actions/PersonalDetails.js index fff00ea6a2d7..bd729a55e9b6 100644 --- a/src/libs/actions/PersonalDetails.js +++ b/src/libs/actions/PersonalDetails.js @@ -256,6 +256,10 @@ function fetchCurrencyPreferences() { const coords = {}; let currency = ''; + Onyx.merge(ONYXKEYS.IOU, { + isRetrievingCurrency: true, + }); + API.GetPreferredCurrency({...coords}) .then((data) => { currency = data.currency; @@ -269,7 +273,12 @@ function fetchCurrencyPreferences() { preferredCurrencySymbol: currencyList[currency].symbol, }); }) - .catch(error => console.debug(`Error fetching currency preference: , ${error}`)); + .catch(error => console.debug(`Error fetching currency preference: , ${error}`)) + .finally(() => { + Onyx.merge(ONYXKEYS.IOU, { + isRetrievingCurrency: false, + }); + }); } /** diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index 36f130e6f76e..b8eb3e0c9ce4 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -53,8 +53,8 @@ const propTypes = { /** Whether or not transaction creation has resulted to error */ error: PropTypes.bool, - // is loading - loading: PropTypes.bool, + /** Flag to show a loading indicator and avoid showing a previously selected currency */ + isRetrievingCurrency: PropTypes.bool, }).isRequired, /** Personal details of all the users */ @@ -303,8 +303,10 @@ class IOUModal extends Component { - - {didScreenTransitionEnd && ( + + {didScreenTransitionEnd && !this.props.iou.isRetrievingCurrency && ( <> {currentStep === Steps.IOUAmount && (