From 88389839856eccf3c3225248a4bc3150a3cfb49b Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 23 Aug 2023 16:26:39 +0700 Subject: [PATCH 1/2] fix: wrong currency in request money pageafter login --- src/libs/actions/IOU.js | 10 ++++++++++ src/pages/iou/steps/NewRequestAmountPage.js | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index ee9afa8b0eb8..799dab521bf7 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -21,6 +21,7 @@ import * as ErrorUtils from '../ErrorUtils'; import * as UserUtils from '../UserUtils'; import * as Report from './Report'; import * as NumberUtils from '../NumberUtils'; +import * as SessionUtils from '../SessionUtils'; let allReports; Onyx.connect({ @@ -51,11 +52,20 @@ Onyx.connect({ }, }); +let shouldResetIOUAfterLogin = true; let currentUserPersonalDetails = {}; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (val) => { currentUserPersonalDetails = lodashGet(val, userAccountID, {}); + if (val && SessionUtils.didUserLogInDuringSession() && shouldResetIOUAfterLogin) { + // eslint-disable-next-line no-use-before-define + resetMoneyRequestInfo(); + shouldResetIOUAfterLogin = false; + Onyx.merge(ONYXKEYS.IOU, { + didInitCurrency: true, + }); + } }, }); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index e0199d72b01a..1c35c39bb4a8 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -20,6 +20,7 @@ import FullPageNotFoundView from '../../../components/BlockingViews/FullPageNotF import styles from '../../../styles/styles'; import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import ScreenWrapper from '../../../components/ScreenWrapper'; +import FullScreenLoadingIndicator from '../../../components/FullscreenLoadingIndicator'; const propTypes = { route: PropTypes.shape({ @@ -172,6 +173,10 @@ function NewRequestAmountPage({route, iou, report}) { /> ); + if (!lodashGet(iou, 'didInitCurrency', false)) { + return ; + } + // 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 which has it's own ScreenWrapper if (!isEditing) { From 52edc8d39b7df59f5f6d1a9cc3c319f37c6db033 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 29 Aug 2023 00:29:29 +0700 Subject: [PATCH 2/2] fix loader on already logged in --- src/libs/actions/IOU.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index e5cf474ab8bf..a74409dcdf00 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -21,7 +21,6 @@ import * as ErrorUtils from '../ErrorUtils'; import * as UserUtils from '../UserUtils'; import * as Report from './Report'; import * as NumberUtils from '../NumberUtils'; -import * as SessionUtils from '../SessionUtils'; let allReports; Onyx.connect({ @@ -52,20 +51,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 && SessionUtils.didUserLogInDuringSession() && shouldResetIOUAfterLogin) { - // eslint-disable-next-line no-use-before-define - resetMoneyRequestInfo(); - shouldResetIOUAfterLogin = false; - Onyx.merge(ONYXKEYS.IOU, { - didInitCurrency: true, - }); + if (!val || !shouldResetIOUAfterLogin || didInitCurrency) { + return; } + // eslint-disable-next-line no-use-before-define + resetMoneyRequestInfo(); + shouldResetIOUAfterLogin = false; + Onyx.merge(ONYXKEYS.IOU, { + didInitCurrency: true, + }); }, });