-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Only create 1 free workspace when transitioning #8611
Changes from all commits
fc2f02d
604bd2e
a00a3a1
b2b2eec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @neil-marcellini Can you provide please just a quick explanation of why we need this? It seems like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I put up this PR before I had figured out that Onyx.clear() was resetting the session silently. I will run the tests with #8736 merged into the feature branch instead of this PR, and if it works then we won't need these changes. |
||
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, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Can we leave suggestion: Put it back the way it was if possible or if not make the functions that call |
||
}); | ||
} | ||
|
||
/** | ||
|
@@ -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, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is there a reason why we are using
null
vs. just defaultingsession
to an empty object?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we use _.isNull which will return false if email is undefined, so it could determine that we are logging in as a new user when we are not. I think that's why I did this
App/src/libs/Navigation/AppNavigator/AuthScreens.js
Line 215 in 604bd2e