From 7f70bd554a12c9370f23170374f4d61de6d7078d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horus=20Lugo=20L=C3=B3pez?= Date: Mon, 14 Jun 2021 13:47:20 +0200 Subject: [PATCH 1/3] Display full screen indicator while fetching currency data --- src/libs/actions/PersonalDetails.js | 11 ++++++++++- src/pages/iou/IOUModal.js | 9 +++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/PersonalDetails.js b/src/libs/actions/PersonalDetails.js index fff00ea6a2d7..417806d8d337 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.MY_PERSONAL_DETAILS, { + 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.MY_PERSONAL_DETAILS, { + isRetrievingCurrency: false, + }); + }); } /** diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index 36f130e6f76e..9751ae245806 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -43,6 +43,9 @@ const propTypes = { // Currency Symbol of the Preferred Currency preferredCurrencySymbol: PropTypes.string, + + // Loading + isRetrievingCurrency: PropTypes.bool, }), // Holds data related to IOU view state, rather than the underlying IOU data. @@ -303,8 +306,10 @@ class IOUModal extends Component { - - {didScreenTransitionEnd && ( + + {didScreenTransitionEnd && !this.props.myPersonalDetails.isRetrievingCurrency && ( <> {currentStep === Steps.IOUAmount && ( Date: Tue, 15 Jun 2021 13:47:45 +0200 Subject: [PATCH 2/3] Move isRetrievingCurrency key to the IOU object --- src/Expensify.js | 4 +++- src/libs/actions/PersonalDetails.js | 4 ++-- src/pages/iou/IOUModal.js | 10 +++++----- 3 files changed, 10 insertions(+), 8 deletions(-) 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 417806d8d337..bd729a55e9b6 100644 --- a/src/libs/actions/PersonalDetails.js +++ b/src/libs/actions/PersonalDetails.js @@ -256,7 +256,7 @@ function fetchCurrencyPreferences() { const coords = {}; let currency = ''; - Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, { + Onyx.merge(ONYXKEYS.IOU, { isRetrievingCurrency: true, }); @@ -275,7 +275,7 @@ function fetchCurrencyPreferences() { }) .catch(error => console.debug(`Error fetching currency preference: , ${error}`)) .finally(() => { - Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, { + Onyx.merge(ONYXKEYS.IOU, { isRetrievingCurrency: false, }); }); diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index 9751ae245806..5974b335ebf6 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -43,9 +43,6 @@ const propTypes = { // Currency Symbol of the Preferred Currency preferredCurrencySymbol: PropTypes.string, - - // Loading - isRetrievingCurrency: PropTypes.bool, }), // Holds data related to IOU view state, rather than the underlying IOU data. @@ -58,6 +55,9 @@ const propTypes = { // is loading loading: PropTypes.bool, + + // Loading + isRetrievingCurrency: PropTypes.bool, }).isRequired, /** Personal details of all the users */ @@ -307,9 +307,9 @@ class IOUModal extends Component { - {didScreenTransitionEnd && !this.props.myPersonalDetails.isRetrievingCurrency && ( + {didScreenTransitionEnd && !this.props.iou.isRetrievingCurrency && ( <> {currentStep === Steps.IOUAmount && ( Date: Tue, 15 Jun 2021 16:34:16 +0200 Subject: [PATCH 3/3] Remove loading flag from the proptype object --- src/pages/iou/IOUModal.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index 5974b335ebf6..b8eb3e0c9ce4 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -53,10 +53,7 @@ const propTypes = { /** Whether or not transaction creation has resulted to error */ error: PropTypes.bool, - // is loading - loading: PropTypes.bool, - - // Loading + /** Flag to show a loading indicator and avoid showing a previously selected currency */ isRetrievingCurrency: PropTypes.bool, }).isRequired,