diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 944dcfa52e9..3c036e32e30 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -79,17 +79,30 @@ const modalScreenListeners = { }; const propTypes = { + + /** Is a workspace currently being created for the user? */ + isCreatingWorkspace: PropTypes.bool, + /** Information about the network */ network: PropTypes.shape({ /** Is the network currently offline or not */ isOffline: PropTypes.bool, }), + /** Session info for the currently logged in user. */ + session: PropTypes.shape({ + + /** Currently logged in user email */ + email: PropTypes.string, + }), + ...windowDimensionsPropTypes, }; const defaultProps = { + isCreatingWorkspace: false, network: {isOffline: true}, + session: {email: null}, }; class AuthScreens extends React.Component { @@ -191,6 +204,10 @@ class AuthScreens extends React.Component { return false; } + if (this.props.isCreatingWorkspace) { + return false; + } + const path = new URL(url).pathname; const params = new URLSearchParams(url); const exitTo = params.get('exitTo'); @@ -370,6 +387,9 @@ AuthScreens.defaultProps = defaultProps; export default compose( withWindowDimensions, withOnyx({ + isCreatingWorkspace: { + key: ONYXKEYS.IS_CREATING_WORKSPACE, + }, network: { key: ONYXKEYS.NETWORK, }, diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index b4939272b05..b1f52a9bf32 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -120,7 +120,6 @@ function create(name = '') { let res = null; return API.Policy_Create({type: CONST.POLICY.TYPE.FREE, policyName: name}) .then((response) => { - Onyx.set(ONYXKEYS.IS_CREATING_WORKSPACE, false); if (response.jsonCode !== 200) { // Show the user feedback const errorMessage = Localize.translateLocal('workspace.new.genericFailureMessage'); @@ -157,7 +156,10 @@ function navigateToPolicy(policyID) { * @param {String} [name] */ function createAndNavigate(name = '') { - create(name).then(navigateToPolicy); + create(name).then(() => { + navigateToPolicy(); + Onyx.set(ONYXKEYS.IS_CREATING_WORKSPACE, false); + }); } /** @@ -228,6 +230,7 @@ function createAndGetPolicyList() { .then(() => { Navigation.dismissModal(); navigateToPolicy(newPolicyID); + Onyx.set(ONYXKEYS.IS_CREATING_WORKSPACE, false); }); } @@ -509,7 +512,6 @@ export { removeMembers, invite, isAdminOfFreePolicy, - create, uploadAvatar, update, setWorkspaceErrors, diff --git a/src/pages/LogInWithShortLivedTokenPage.js b/src/pages/LogInWithShortLivedTokenPage.js index dbb5763ec2a..9b35d70064e 100644 --- a/src/pages/LogInWithShortLivedTokenPage.js +++ b/src/pages/LogInWithShortLivedTokenPage.js @@ -69,7 +69,14 @@ class LogInWithShortLivedTokenPage extends Component { } Log.info('[LoginWithShortLivedTokenPage] User is signed in'); + this.navigateToExitRoute(); + } + componentDidUpdate() { + this.navigateToExitRoute(); + } + + navigateToExitRoute() { // exitTo is URI encoded because it could contain a variable number of slashes (i.e. "workspace/new" vs "workspace//card") const exitTo = decodeURIComponent(lodashGet(this.props.route.params, 'exitTo', '')); if (exitTo === ROUTES.WORKSPACE_NEW) {