Skip to content

Commit cc912ff

Browse files
authored
Merge pull request #8817 from Expensify/justice_refetchActions-PaymentsPage.js
Re-fetch actions when we move from offline to online in Payments Page
2 parents 9ab001c + abefcba commit cc912ff

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import * as Expensicons from '../../../../components/Icon/Expensicons';
3030
import ConfirmModal from '../../../../components/ConfirmModal';
3131
import KYCWall from '../../../../components/KYCWall';
3232
import {propTypes, defaultProps} from './paymentsPagePropTypes';
33+
import {withNetwork} from '../../../../components/OnyxProvider';
3334

3435
class BasePaymentsPage extends React.Component {
3536
constructor(props) {
@@ -60,12 +61,20 @@ class BasePaymentsPage extends React.Component {
6061
}
6162

6263
componentDidMount() {
63-
PaymentMethods.getPaymentMethods();
64+
this.fetchData();
6465
if (this.props.shouldListenForResize) {
6566
this.dimensionsSubscription = Dimensions.addEventListener('change', this.setMenuPosition);
6667
}
6768
}
6869

70+
componentDidUpdate(prevProps) {
71+
if (!prevProps.network.isOffline || this.props.network.isOffline) {
72+
return;
73+
}
74+
75+
this.fetchData();
76+
}
77+
6978
componentWillUnmount() {
7079
if (!this.props.shouldListenForResize || !this.dimensionsSubscription) {
7180
return;
@@ -186,6 +195,10 @@ class BasePaymentsPage extends React.Component {
186195
throw new Error('Invalid payment method type selected');
187196
}
188197

198+
fetchData() {
199+
PaymentMethods.getPaymentMethods();
200+
}
201+
189202
/**
190203
* Hide the add payment modal
191204
*/
@@ -432,6 +445,7 @@ BasePaymentsPage.defaultProps = defaultProps;
432445
export default compose(
433446
withWindowDimensions,
434447
withLocalize,
448+
withNetwork(),
435449
withOnyx({
436450
betas: {
437451
key: ONYXKEYS.BETAS,

src/pages/settings/Payments/PaymentsPage/paymentsPagePropTypes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
22
import walletTransferPropTypes from '../walletTransferPropTypes';
33
import {withLocalizePropTypes} from '../../../../components/withLocalize';
44
import {windowDimensionsPropTypes} from '../../../../components/withWindowDimensions';
5+
import networkPropTypes from '../../../../components/networkPropTypes';
56

67
const propTypes = {
78
/** Wallet balance transfer props */
@@ -22,6 +23,9 @@ const propTypes = {
2223
currentBalance: PropTypes.number,
2324
}),
2425

26+
/** Information about the network */
27+
network: networkPropTypes.isRequired,
28+
2529
...withLocalizePropTypes,
2630

2731
...windowDimensionsPropTypes,

0 commit comments

Comments
 (0)