diff --git a/src/libs/Network.js b/src/libs/Network.js index 16df44404de..5116cc2d002 100644 --- a/src/libs/Network.js +++ b/src/libs/Network.js @@ -109,13 +109,9 @@ function processNetworkRequestQueue() { } // If we have a request then we need to check if it can be persisted in case we close the tab while offline - const retryableRequests = []; - _.each(networkRequestQueue, (request) => { - if ((request.data.doNotRetry || request.data.forceNetworkRequest) && !request.data.persist) { - return request.resolve(); - } - retryableRequests.push(request); - }); + const retryableRequests = _.filter(networkRequestQueue, request => ( + !request.data.doNotRetry && request.data.persist + )); Onyx.set(ONYXKEYS.NETWORK_REQUEST_QUEUE, retryableRequests); return; } diff --git a/src/libs/actions/PersonalDetails.js b/src/libs/actions/PersonalDetails.js index 1a67d9fba89..c57b81e95c0 100644 --- a/src/libs/actions/PersonalDetails.js +++ b/src/libs/actions/PersonalDetails.js @@ -243,7 +243,7 @@ function fetchCurrencyPreferences() { isRetrievingCurrency: true, }); - API.GetPreferredCurrency({...coords, doNotRetry: true}) + API.GetPreferredCurrency({...coords}) .then((data) => { currency = data.currency; }) diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index 8efb9fbdbfa..a64c15b8da9 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -34,6 +34,12 @@ const propTypes = { // Currency Symbol of the Preferred Currency preferredCurrencySymbol: PropTypes.string, + + // Preferred Currency Code of the current user + selectedCurrencyCode: PropTypes.string, + + // Currency Symbol of the Preferred Currency + selectedCurrencySymbol: PropTypes.string, }), // The currency list constant object from Onyx @@ -51,7 +57,12 @@ const propTypes = { }; const defaultProps = { - myPersonalDetails: {preferredCurrencyCode: CONST.CURRENCY.USD, preferredCurrencySymbol: '$'}, + myPersonalDetails: { + preferredCurrencyCode: CONST.CURRENCY.USD, + preferredCurrencySymbol: '$', + selectedCurrencyCode: CONST.CURRENCY.USD, + selectedCurrencySymbol: '$', + }, currencyList: {}, }; @@ -151,8 +162,8 @@ class IOUCurrencySelection extends Component { */ confirmCurrencySelection() { Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, { - preferredCurrencyCode: this.state.selectedCurrency.currencyCode, - preferredCurrencySymbol: this.state.selectedCurrency.currencySymbol, + selectedCurrencyCode: this.state.selectedCurrency.currencyCode, + selectedCurrencySymbol: this.state.selectedCurrency.currencySymbol, }); Navigation.goBack(); } diff --git a/src/pages/iou/IOUModal.js b/src/pages/iou/IOUModal.js index 63d15d2e966..ee4e0cf9b1d 100755 --- a/src/pages/iou/IOUModal.js +++ b/src/pages/iou/IOUModal.js @@ -2,14 +2,13 @@ import React, {Component} from 'react'; import {View, TouchableOpacity} from 'react-native'; import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; -import {withOnyx} from 'react-native-onyx'; +import Onyx, {withOnyx} from 'react-native-onyx'; import IOUAmountPage from './steps/IOUAmountPage'; import IOUParticipantsPage from './steps/IOUParticipantsPage'; import IOUConfirmPage from './steps/IOUConfirmPage'; import Header from '../../components/Header'; import styles from '../../styles/styles'; import Icon from '../../components/Icon'; -import * as PersonalDetails from '../../libs/actions/PersonalDetails'; import {createIOUSplit, createIOUTransaction} from '../../libs/actions/IOU'; import {Close, BackArrow} from '../../components/Icon/Expensicons'; import Navigation from '../../libs/Navigation/Navigation'; @@ -46,6 +45,12 @@ const propTypes = { // Currency Symbol of the Preferred Currency preferredCurrencySymbol: PropTypes.string, + + // Selected Currency Code of the current IOU + selectedCurrencyCode: PropTypes.string, + + // Currency Symbol of the Selected Currency + selectedCurrencySymbol: PropTypes.string, }), // Holds data related to IOU view state, rather than the underlying IOU data. @@ -83,6 +88,8 @@ const defaultProps = { myPersonalDetails: { preferredCurrencyCode: CONST.CURRENCY.USD, preferredCurrencySymbol: '$', + selectedCurrencyCode: CONST.CURRENCY.USD, + selectedCurrencySymbol: '$', }, iouType: '', }; @@ -103,7 +110,6 @@ class IOUModal extends Component { this.addParticipants = this.addParticipants.bind(this); this.createTransaction = this.createTransaction.bind(this); this.updateComment = this.updateComment.bind(this); - this.getReady = this.getReady.bind(this); const participants = lodashGet(props, 'report.participants', []); const participantsWithDetails = getPersonalDetailsForLogins(participants, props.personalDetails) .map(personalDetails => ({ @@ -142,17 +148,20 @@ class IOUModal extends Component { Navigation.dismissModal(); } - if (prevProps.myPersonalDetails.preferredCurrencyCode - !== this.props.myPersonalDetails.preferredCurrencyCode) { + if (prevProps.myPersonalDetails.selectedCurrencyCode + !== this.props.myPersonalDetails.selectedCurrencyCode) { this.updateSelectedCurrency({ - currencyCode: this.props.myPersonalDetails.preferredCurrencyCode, - currencySymbol: this.props.myPersonalDetails.preferredCurrencySymbol, + currencyCode: this.props.myPersonalDetails.selectedCurrencyCode, + currencySymbol: this.props.myPersonalDetails.selectedCurrencySymbol, }); } } - getReady() { - PersonalDetails.fetchCurrencyPreferences(); + componentWillUnmount() { + Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, { + selectedCurrencyCode: this.props.myPersonalDetails.preferredCurrencyCode, + selectedCurrencySymbol: this.props.myPersonalDetails.preferredCurrencySymbol, + }); } /** @@ -280,7 +289,7 @@ class IOUModal extends Component { const currentStep = this.steps[this.state.currentStepIndex]; const reportID = lodashGet(this.props, 'route.params.reportID', ''); return ( - + {({didScreenTransitionEnd}) => ( @@ -317,9 +326,9 @@ class IOUModal extends Component { - {didScreenTransitionEnd && !this.props.iou.isRetrievingCurrency && ( + {didScreenTransitionEnd && ( <> {currentStep === Steps.IOUAmount && (