Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display full-screen loading indicator while fetching currency data #3577

Merged
merged 3 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/Expensify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion src/libs/actions/PersonalDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ function fetchCurrencyPreferences() {
const coords = {};
let currency = '';

Onyx.merge(ONYXKEYS.IOU, {
isRetrievingCurrency: true,
});

API.GetPreferredCurrency({...coords})
.then((data) => {
currency = data.currency;
Expand All @@ -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,
});
});
}

/**
Expand Down
10 changes: 6 additions & 4 deletions src/pages/iou/IOUModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -303,8 +303,10 @@ class IOUModal extends Component {
</View>
</View>
<View style={[styles.pRelative, styles.flex1]}>
<FullScreenLoadingIndicator visible={!didScreenTransitionEnd} />
{didScreenTransitionEnd && (
<FullScreenLoadingIndicator
visible={!didScreenTransitionEnd || this.props.iou.isRetrievingCurrency}
/>
{didScreenTransitionEnd && !this.props.iou.isRetrievingCurrency && (
<>
{currentStep === Steps.IOUAmount && (
<IOUAmountPage
Expand Down