diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index ba720e3f789a..ff370c7ef42e 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -96,6 +96,22 @@ const modalScreenListeners = { }, }; +let hasLoadedPolicies = false; + +/** + * We want to only load policy info if you are in the freePlan beta. + * @param {Array} betas + */ +function loadPoliciesBehindBeta(betas) { + // When removing the freePlan beta, simply load the policyList and the policySummaries in componentDidMount(). + // Policy info loading should not be blocked behind the defaultRooms beta alone. + if (!hasLoadedPolicies && (Permissions.canUseFreePlan(betas) || Permissions.canUseDefaultRooms(betas))) { + getPolicyList(); + getPolicySummaries(); + hasLoadedPolicies = true; + } +} + const propTypes = { /** Information about the network */ network: PropTypes.shape({ @@ -142,10 +158,7 @@ class AuthScreens extends React.Component { fetchCountryCodeByRequestIP(); UnreadIndicatorUpdater.listenForReportChanges(); - if (Permissions.canUseFreePlan(this.props.betas) || Permissions.canUseDefaultRooms(this.props.betas)) { - getPolicyList(); - getPolicySummaries(); - } + loadPoliciesBehindBeta(this.props.betas); // Refresh the personal details, timezone and betas every 30 minutes // There is no pusher event that sends updated personal details data yet @@ -186,9 +199,17 @@ class AuthScreens extends React.Component { return true; } + if (nextProps.betas !== this.props.betas) { + return true; + } + return false; } + componentDidUpdate() { + loadPoliciesBehindBeta(this.props.betas); + } + componentWillUnmount() { KeyboardShortcut.unsubscribe('K'); NetworkConnection.stopListeningForReconnect();