Skip to content

Commit

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

Offline/Online toggle data fetch for workspace settings page
  • Loading branch information
AndrewGable authored May 12, 2022
2 parents 6c31393 + 4f57b9f commit f390e27
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/pages/workspace/WorkspaceSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ import FixedFooter from '../../components/FixedFooter';
import WorkspacePageWithSections from './WorkspacePageWithSections';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import withFullPolicy, {fullPolicyPropTypes, fullPolicyDefaultProps} from './withFullPolicy';
import {withNetwork} from '../../components/OnyxProvider';
import networkPropTypes from '../../components/networkPropTypes';

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

/** List of betas */
betas: PropTypes.arrayOf(PropTypes.string),

...fullPolicyPropTypes,

...withLocalizePropTypes,
};

const defaultProps = {
betas: [],

Expand All @@ -58,7 +64,15 @@ class WorkspaceSettingsPage extends React.Component {
}

componentDidMount() {
PersonalDetails.getCurrencyList();
this.fetchData();
}

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

this.fetchData();
}

/**
Expand All @@ -72,6 +86,10 @@ class WorkspaceSettingsPage extends React.Component {
}));
}

fetchData() {
PersonalDetails.getCurrencyList();
}

removeAvatar() {
this.setState({previewAvatarURL: ''});
Policy.update(this.props.policy.id, {avatarURL: ''}, true);
Expand Down Expand Up @@ -196,4 +214,5 @@ export default compose(
currencyList: {key: ONYXKEYS.CURRENCY_LIST},
}),
withLocalize,
withNetwork(),
)(WorkspaceSettingsPage);

0 comments on commit f390e27

Please sign in to comment.