Don’t fetch project metadata until we have the token

This commit is contained in:
rschamp 2022-05-06 14:36:14 -04:00
parent 8b4c692e33
commit 9eb1b44098

View file

@ -142,13 +142,16 @@ class Preview extends React.Component {
this.props.sessionStatus === sessionActions.Status.FETCHED) || this.props.sessionStatus === sessionActions.Status.FETCHED) ||
(this.state.projectId !== prevState.projectId))) { (this.state.projectId !== prevState.projectId))) {
this.fetchCommunityData(); this.fetchCommunityData();
this.getProjectData(this.state.projectId, true /* Show cloud/username alerts */);
if (this.state.justShared) { if (this.state.justShared) {
this.setState({ // eslint-disable-line react/no-did-update-set-state this.setState({ // eslint-disable-line react/no-did-update-set-state
justShared: false justShared: false
}); });
} }
} }
if (this.props.projectInfo.id !== prevProps.projectInfo.id) {
storage.setProjectToken(this.props.projectInfo.project_token);
this.getProjectData(this.state.projectId, true /* Show cloud/username alerts */);
}
if (this.state.projectId === '0' && this.state.projectId !== prevState.projectId) { if (this.state.projectId === '0' && this.state.projectId !== prevState.projectId) {
this.props.resetProject(); this.props.resetProject();
if (this.state.justRemixed || this.state.justShared) { if (this.state.justRemixed || this.state.justShared) {
@ -159,7 +162,6 @@ class Preview extends React.Component {
} }
} }
if (this.props.projectInfo.id !== prevProps.projectInfo.id) { if (this.props.projectInfo.id !== prevProps.projectInfo.id) {
storage.setProjectToken(this.props.projectInfo.project_token);
if (typeof this.props.projectInfo.id === 'undefined') { if (typeof this.props.projectInfo.id === 'undefined') {
this.initCounts(0, 0); this.initCounts(0, 0);
} else { } else {
@ -197,6 +199,7 @@ class Preview extends React.Component {
// Switching out of editor mode, refresh data that comes from project json // Switching out of editor mode, refresh data that comes from project json
if (this.props.playerMode && !prevProps.playerMode) { if (this.props.playerMode && !prevProps.playerMode) {
storage.setProjectToken(this.props.projectInfo.project_token);
this.getProjectData( this.getProjectData(
this.state.projectId, this.state.projectId,
false // Do not show cloud/username alerts again false // Do not show cloud/username alerts again