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

Re-fetch actions when we move from offline to online in Payments Page #8817

Merged
merged 5 commits into from
May 18, 2022
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
16 changes: 15 additions & 1 deletion src/pages/settings/Payments/PaymentsPage/BasePaymentsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import * as Expensicons from '../../../../components/Icon/Expensicons';
import ConfirmModal from '../../../../components/ConfirmModal';
import KYCWall from '../../../../components/KYCWall';
import {propTypes, defaultProps} from './paymentsPagePropTypes';
import {withNetwork} from '../../../../components/OnyxProvider';

class BasePaymentsPage extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -60,12 +61,20 @@ class BasePaymentsPage extends React.Component {
}

componentDidMount() {
PaymentMethods.getPaymentMethods();
this.fetchData();
if (this.props.shouldListenForResize) {
this.dimensionsSubscription = Dimensions.addEventListener('change', this.setMenuPosition);
}
}

componentDidUpdate(prevProps) {
if (!prevProps.network.isOffline || this.props.network.isOffline) {
return;
}
Justicea83 marked this conversation as resolved.
Show resolved Hide resolved

this.fetchData();
}

componentWillUnmount() {
if (!this.props.shouldListenForResize || !this.dimensionsSubscription) {
return;
Expand Down Expand Up @@ -186,6 +195,10 @@ class BasePaymentsPage extends React.Component {
throw new Error('Invalid payment method type selected');
}

fetchData() {
PaymentMethods.getPaymentMethods();
Justicea83 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Hide the add payment modal
*/
Expand Down Expand Up @@ -432,6 +445,7 @@ BasePaymentsPage.defaultProps = defaultProps;
export default compose(
withWindowDimensions,
withLocalize,
withNetwork(),
withOnyx({
betas: {
key: ONYXKEYS.BETAS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import walletTransferPropTypes from '../walletTransferPropTypes';
import {withLocalizePropTypes} from '../../../../components/withLocalize';
import {windowDimensionsPropTypes} from '../../../../components/withWindowDimensions';
import networkPropTypes from '../../../../components/networkPropTypes';

const propTypes = {
/** Wallet balance transfer props */
Expand All @@ -22,6 +23,9 @@ const propTypes = {
currentBalance: PropTypes.number,
}),

/** Information about the network */
network: networkPropTypes.isRequired,

...withLocalizePropTypes,

...windowDimensionsPropTypes,
Expand Down