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

Fix: Wrong currency in request money page after login #25786

Merged
merged 12 commits into from
Sep 25, 2023
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
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned that this is a hack that does not address the root cause of the problem. I think it is a mistake that the IOU in Onyx is the thing in charge of initializing currency.

I suggest reverting this PR since it has already been linked to a regression: #28280 and go back to the drawing board for a better solution.

Alternatively, you can wait for me to make progress and resolve #26538 which is an attempt to clean up a lot of the messing routing logic that is probably closer to the root of the problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm working on it.

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 @@ -165,6 +166,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
Loading