Skip to content

Commit

Permalink
Merge pull request #25786 from tienifr/fix/24393
Browse files Browse the repository at this point in the history
Fix: Wrong currency in request money page after login
  • Loading branch information
cristipaval authored Sep 25, 2023
2 parents 34d58a0 + ecb657b commit df6e2b6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,29 @@ Onyx.connect({
},
});

let didInitCurrency = false;
Onyx.connect({
key: ONYXKEYS.IOU,
callback: (val) => {
didInitCurrency = lodashGet(val, 'didInitCurrency');
},
});

let shouldResetIOUAfterLogin = true;
let currentUserPersonalDetails = {};
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (val) => {
currentUserPersonalDetails = lodashGet(val, userAccountID, {});
if (!val || !shouldResetIOUAfterLogin || didInitCurrency) {
return;
}
// eslint-disable-next-line no-use-before-define
resetMoneyRequestInfo();
shouldResetIOUAfterLogin = false;
Onyx.merge(ONYXKEYS.IOU, {
didInitCurrency: true,
});
},
});

Expand Down
5 changes: 5 additions & 0 deletions src/pages/iou/steps/NewRequestAmountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import HeaderWithBackButton from '../../../components/HeaderWithBackButton';
import ScreenWrapper from '../../../components/ScreenWrapper';
import {iouPropTypes, iouDefaultProps} from '../propTypes';
import CONST from '../../../CONST';
import FullScreenLoadingIndicator from '../../../components/FullscreenLoadingIndicator';

const propTypes = {
/** React Navigation route */
Expand Down Expand Up @@ -160,6 +161,10 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) {
/>
);

if (!lodashGet(iou, 'didInitCurrency', false)) {
return <FullScreenLoadingIndicator />;
}

// ScreenWrapper is only needed in edit mode because we have a dedicated route for the edit amount page (MoneyRequestEditAmountPage).
// The rest of the cases this component is rendered through <MoneyRequestSelectorPage /> which has it's own ScreenWrapper
if (!isEditing) {
Expand Down

0 comments on commit df6e2b6

Please sign in to comment.