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

🍒 Cherry pick PR #4019 to staging 🍒 #4193

Merged
merged 2 commits into from
Jul 23, 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: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001007903
versionName "1.0.79-3"
versionCode 1001007904
versionName "1.0.79-4"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCash/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.0.79.3</string>
<string>1.0.79.4</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ExpensifyCashTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.79.3</string>
<string>1.0.79.4</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "expensify.cash",
"version": "1.0.79-3",
"version": "1.0.79-4",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "Expensify.cash is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
2 changes: 1 addition & 1 deletion src/CONST.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 30 additions & 16 deletions src/components/IOUConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@ import SafeAreaInsetPropTypes from '../pages/SafeAreaInsetPropTypes';
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions';
import compose from '../libs/compose';
import FixedFooter from './FixedFooter';
import CONST from '../CONST';

const propTypes = {
/** Callback to inform parent modal of success */
onConfirm: PropTypes.func.isRequired,

// User's currency preference
selectedCurrency: PropTypes.shape({
// Currency code for the selected currency
currencyCode: PropTypes.string,

// Currency symbol for the selected currency
currencySymbol: PropTypes.string,
}).isRequired,

// Callback to update comment from IOUModal
onUpdateComment: PropTypes.func,

Expand Down Expand Up @@ -80,20 +72,33 @@ const propTypes = {

/** Primary login of the user */
login: PropTypes.string,
}).isRequired,
}),

/** Holds data related to IOU view state, rather than the underlying IOU data. */
iou: PropTypes.shape({

/** Whether or not the IOU step is loading (creating the IOU Report) */
loading: PropTypes.bool,

// Selected Currency Code of the current IOU
selectedCurrencyCode: PropTypes.string,
}),

/** Information about the network */
network: PropTypes.shape({
/** Is the network currently offline or not */
isOffline: PropTypes.bool,
}),
};

const defaultProps = {
iou: {},
iou: {
selectedCurrencyCode: CONST.CURRENCY.USD,
},
onUpdateComment: null,
comment: '',
network: {},
myPersonalDetails: {},
};

// Gives minimum height to offset the height of
Expand All @@ -115,14 +120,14 @@ class IOUConfirmationList extends Component {
this.props.myPersonalDetails,
this.props.numberFormat(this.calculateAmount() / 100, {
style: 'currency',
currency: this.props.selectedCurrency.currencyCode,
currency: this.props.iou.selectedCurrencyCode,
}),
);

const formattedParticipants = getIOUConfirmationOptionsFromParticipants(this.props.participants,
this.props.numberFormat(this.calculateAmount() / 100, {
style: 'currency',
currency: this.props.selectedCurrency.currencyCode,
currency: this.props.iou.selectedCurrencyCode,
}));

sections.push({
Expand All @@ -141,7 +146,7 @@ class IOUConfirmationList extends Component {
const formattedParticipants = getIOUConfirmationOptionsFromParticipants(this.props.participants,
this.props.numberFormat(this.props.iouAmount, {
style: 'currency',
currency: this.props.selectedCurrency.currencyCode,
currency: this.props.iou.selectedCurrencyCode,
}));

sections.push({
Expand Down Expand Up @@ -237,7 +242,7 @@ class IOUConfirmationList extends Component {
this.props.hasMultipleParticipants ? 'iou.split' : 'iou.request', {
amount: this.props.numberFormat(
this.props.iouAmount,
{style: 'currency', currency: this.props.selectedCurrency.currencyCode},
{style: 'currency', currency: this.props.iou.selectedCurrencyCode},
),
},
);
Expand Down Expand Up @@ -274,10 +279,16 @@ class IOUConfirmationList extends Component {
</View>
</ScrollView>
<FixedFooter>
{this.props.network.isOffline && (
<Text style={[styles.formError, styles.pb2]}>
{this.props.translate('session.offlineMessage')}
</Text>
)}
<Button
success
isDisabled={this.props.network.isOffline}
style={[styles.w100]}
isLoading={this.props.iou.loading}
isLoading={this.props.iou.loading && !this.props.network.isOffline}
text={buttonText}
onPress={() => this.props.onConfirm(this.getSplits())}
pressOnEnter
Expand All @@ -301,5 +312,8 @@ export default compose(
myPersonalDetails: {
key: ONYXKEYS.MY_PERSONAL_DETAILS,
},
network: {
key: ONYXKEYS.NETWORK,
},
}),
)(IOUConfirmationList);
3 changes: 2 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ export default {
},
},
session: {
offlineMessage: 'Looks like you\'re offline. Please check your connection and try again.',
offlineMessageRetry: 'Looks like you\'re offline. Please check your connection and try again.',
offlineMessage: 'Looks like you\'re offline.',
},
workspace: {
common: {
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ export default {
},
},
session: {
offlineMessage: 'Parece que estás desconectado. Por favor chequea tu conexión e inténtalo otra vez',
offlineMessageRetry: 'Parece que estás desconectado. Por favor chequea tu conexión e inténtalo otra vez',
offlineMessage: 'Parece que estás desconectado.',
},
workspace: {
common: {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class AuthScreens extends React.Component {
User.getUserDetails();
User.getBetas();
User.getDomainInfo();
PersonalDetails.fetchCurrencyPreferences();
PersonalDetails.fetchLocalCurrency();
fetchAllReports(true, true);
fetchCountryCodeByRequestIP();
UnreadIndicatorUpdater.listenForReportChanges();
Expand Down
1 change: 0 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma
*
* @param {Object} currencyOptions
* @param {String} searchValue
* @param {Object} selectedCurrency
* @returns {Array}
*/
function getCurrencyListForSections(currencyOptions, searchValue) {
Expand Down
10 changes: 10 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ function rejectTransaction({
});
}

/**
* Sets IOU'S selected currency
*
* @param {String} selectedCurrencyCode
*/
function setIOUSelectedCurrency(selectedCurrencyCode) {
Onyx.merge(ONYXKEYS.IOU, {selectedCurrencyCode});
}

/**
* @private
*
Expand Down Expand Up @@ -239,4 +248,5 @@ export {
createIOUSplit,
rejectTransaction,
payIOUReport,
setIOUSelectedCurrency,
};
15 changes: 5 additions & 10 deletions src/libs/actions/PersonalDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ function getCurrencyList() {
}

/**
* Fetches the Currency preferences based on location and sets currency code/symbol to local storage
* Fetches the local currency based on location and sets currency code/symbol to local storage
*/
function fetchCurrencyPreferences() {
function fetchLocalCurrency() {
const coords = {};
let currency = '';

Expand All @@ -247,14 +247,9 @@ function fetchCurrencyPreferences() {
.then((data) => {
currency = data.currency;
})
.then(API.GetCurrencyList)
.then(getCurrencyList)
.then((currencyList) => {
Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS,
{
preferredCurrencyCode: currency,
preferredCurrencySymbol: currencyList[currency].symbol,
});
.then(() => {
Onyx.merge(ONYXKEYS.MY_PERSONAL_DETAILS, {localCurrencyCode: currency});
})
.catch(error => console.debug(`Error fetching currency preference: , ${error}`))
.finally(() => {
Expand Down Expand Up @@ -302,6 +297,6 @@ export {
setPersonalDetails,
setAvatar,
deleteAvatar,
fetchCurrencyPreferences,
fetchLocalCurrency,
getCurrencyList,
};
2 changes: 1 addition & 1 deletion src/libs/actions/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function fetchAccountDetails(login) {
Onyx.merge(ONYXKEYS.ACCOUNT, {error: response.message});
})
.catch(() => {
Onyx.merge(ONYXKEYS.ACCOUNT, {error: translateLocal('session.offlineMessage')});
Onyx.merge(ONYXKEYS.ACCOUNT, {error: translateLocal('session.offlineMessageRetry')});
})
.finally(() => {
Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false});
Expand Down
Loading