Skip to content

Commit

Permalink
Merge pull request #8946 from Expensify/paulogasparsv-offline-workspa…
Browse files Browse the repository at this point in the history
…ce-page-sections

Offline/Online toggle data fetch for WorkspacePageWithSections
  • Loading branch information
Joel Bettner authored May 16, 2022
2 parents 5c5f79b + 232ec69 commit a499e43
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/pages/workspace/WorkspacePageWithSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ import reimbursementAccountPropTypes from '../ReimbursementAccount/reimbursement
import userPropTypes from '../settings/userPropTypes';
import KeyboardAvoidingView from '../../components/KeyboardAvoidingView';
import withFullPolicy from './withFullPolicy';
import {withNetwork} from '../../components/OnyxProvider';
import networkPropTypes from '../../components/networkPropTypes';

const propTypes = {
/** Information about the network from Onyx */
network: networkPropTypes.isRequired,

/** The text to display in the header */
headerText: PropTypes.string.isRequired,

Expand Down Expand Up @@ -65,6 +70,18 @@ const defaultProps = {

class WorkspacePageWithSections extends React.Component {
componentDidMount() {
this.fetchData();
}

componentDidUpdate(prevProps) {
if (!prevProps.network.isOffline || this.props.network.isOffline) {
return;
}

this.fetchData();
}

fetchData() {
const achState = lodashGet(this.props.reimbursementAccount, 'achData.state', '');
BankAccounts.fetchFreePlanVerifiedBankAccount('', achState);
}
Expand Down Expand Up @@ -118,4 +135,5 @@ export default compose(
},
}),
withFullPolicy,
withNetwork(),
)(WorkspacePageWithSections);

0 comments on commit a499e43

Please sign in to comment.