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

Load policies after we load betas as well #4084

Merged
merged 2 commits into from
Jul 15, 2021
Merged
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
29 changes: 25 additions & 4 deletions src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down