From f1542bbc9f389817b8b30d05eeaf3d24f4955372 Mon Sep 17 00:00:00 2001 From: Paulo Vale Date: Tue, 10 May 2022 13:01:37 -0300 Subject: [PATCH 1/2] Reload WorkspaceSettings data when toggling online --- src/pages/workspace/WorkspaceSettingsPage.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pages/workspace/WorkspaceSettingsPage.js b/src/pages/workspace/WorkspaceSettingsPage.js index a0bb45fcbe6b..ed61616b0854 100644 --- a/src/pages/workspace/WorkspaceSettingsPage.js +++ b/src/pages/workspace/WorkspaceSettingsPage.js @@ -25,8 +25,13 @@ 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), @@ -34,6 +39,7 @@ const propTypes = { ...withLocalizePropTypes, }; + const defaultProps = { betas: [], @@ -58,6 +64,18 @@ class WorkspaceSettingsPage extends React.Component { } componentDidMount() { + this.fetchData(); + } + + componentDidUpdate(prevProps) { + if (!prevProps.network.isOffline || this.props.network.isOffline) { + return; + } + + this.fetchData(); + } + + fetchData() { PersonalDetails.getCurrencyList(); } @@ -196,4 +214,5 @@ export default compose( currencyList: {key: ONYXKEYS.CURRENCY_LIST}, }), withLocalize, + withNetwork(), )(WorkspaceSettingsPage); From 4f57b9f1f9550aaaa92b38125c5fe996a7a6abcc Mon Sep 17 00:00:00 2001 From: Paulo Vale Date: Tue, 10 May 2022 13:02:08 -0300 Subject: [PATCH 2/2] Lint WorkspaceSettingsPage.js methods order --- src/pages/workspace/WorkspaceSettingsPage.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/WorkspaceSettingsPage.js b/src/pages/workspace/WorkspaceSettingsPage.js index ed61616b0854..b9ef37c13a82 100644 --- a/src/pages/workspace/WorkspaceSettingsPage.js +++ b/src/pages/workspace/WorkspaceSettingsPage.js @@ -75,10 +75,6 @@ class WorkspaceSettingsPage extends React.Component { this.fetchData(); } - fetchData() { - PersonalDetails.getCurrencyList(); - } - /** * @returns {Object[]} */ @@ -90,6 +86,10 @@ class WorkspaceSettingsPage extends React.Component { })); } + fetchData() { + PersonalDetails.getCurrencyList(); + } + removeAvatar() { this.setState({previewAvatarURL: ''}); Policy.update(this.props.policy.id, {avatarURL: ''}, true);