From c9d791853248ac21b29cd0943c59743ee2c8cb05 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Fri, 29 Apr 2022 09:05:34 +0000 Subject: [PATCH 1/3] add re-fetch actions to ReimbursementAccountPage.js --- .../ReimbursementAccountPage.js | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index b5ef196ff100..98b055ae0d2f 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -19,6 +19,8 @@ import styles from '../../styles/styles'; import KeyboardAvoidingView from '../../components/KeyboardAvoidingView'; import getPlaidOAuthReceivedRedirectURI from '../../libs/getPlaidOAuthReceivedRedirectURI'; import Text from '../../components/Text'; +import {withNetwork} from '../../components/OnyxProvider'; +import networkPropTypes from '../../components/networkPropTypes'; // Steps import BankAccountStep from './BankAccountStep'; @@ -39,6 +41,9 @@ const propTypes = { /** ACH data for the withdrawal account actively being set up */ reimbursementAccount: reimbursementAccountPropTypes, + /** Information about the network */ + network: networkPropTypes.isRequired, + /** Current session for the user */ session: PropTypes.shape({ /** User login */ @@ -70,14 +75,13 @@ const defaultProps = { class ReimbursementAccountPage extends React.Component { componentDidMount() { - // We can specify a step to navigate to by using route params when the component mounts. - const stepToOpen = this.getStepToOpenFromRouteParams(); - - // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new` - BankAccounts.fetchFreePlanVerifiedBankAccount(stepToOpen !== CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT ? stepToOpen : ''); + this.fetchData(); } componentDidUpdate(prevProps) { + if (prevProps.network.isOffline && !this.props.network.isOffline) { + this.fetchData(); + } const currentStep = lodashGet( this.props, 'reimbursementAccount.achData.currentStep', @@ -144,6 +148,14 @@ class ReimbursementAccountPage extends React.Component { } } + fetchData() { + // We can specify a step to navigate to by using route params when the component mounts. + const stepToOpen = this.getStepToOpenFromRouteParams(); + + // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new` + BankAccounts.fetchFreePlanVerifiedBankAccount(stepToOpen !== CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT ? stepToOpen : ''); + } + render() { if (!Permissions.canUseFreePlan(this.props.betas)) { Log.info('Not showing new bank account page because user is not on free plan beta'); @@ -243,6 +255,7 @@ ReimbursementAccountPage.propTypes = propTypes; ReimbursementAccountPage.defaultProps = defaultProps; export default compose( + withNetwork(), withOnyx({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, From 2f835e75fc22636101c0bc24465632c947043b47 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Mon, 23 May 2022 09:47:47 +0000 Subject: [PATCH 2/3] step to open comments updates --- src/pages/ReimbursementAccount/ReimbursementAccountPage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 98b055ae0d2f..46c450094609 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -149,7 +149,8 @@ class ReimbursementAccountPage extends React.Component { } fetchData() { - // We can specify a step to navigate to by using route params when the component mounts. + // We can specify a step to navigate to by using route params when the component mounts or when the network status changes. + // We initialize this variable because the route parameters may have changed when we toggle between offline and online states. const stepToOpen = this.getStepToOpenFromRouteParams(); // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new` From c67ac1f9acc5c542a4a222b09823ac34ee451fb8 Mon Sep 17 00:00:00 2001 From: Justice Arthur Date: Tue, 24 May 2022 16:56:35 +0000 Subject: [PATCH 3/3] update comments --- src/pages/ReimbursementAccount/ReimbursementAccountPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 46c450094609..d81900e666f1 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -149,8 +149,8 @@ class ReimbursementAccountPage extends React.Component { } fetchData() { - // We can specify a step to navigate to by using route params when the component mounts or when the network status changes. - // We initialize this variable because the route parameters may have changed when we toggle between offline and online states. + // We can specify a step to navigate to by using route params when the component mounts. + // We want to use the same stepToOpen variable when the network state changes because we can be redirected to a different step when the account refreshes. const stepToOpen = this.getStepToOpenFromRouteParams(); // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new`