Fix(map): prevent loading a challenge from refetching
This commit is contained in:
		@@ -34,9 +34,11 @@ const bindableActions = {
 | 
				
			|||||||
const mapStateToProps = createSelector(
 | 
					const mapStateToProps = createSelector(
 | 
				
			||||||
  challengeSelector,
 | 
					  challengeSelector,
 | 
				
			||||||
  state => state.challengesApp.challenge,
 | 
					  state => state.challengesApp.challenge,
 | 
				
			||||||
    ({ viewType }, challenge) => ({
 | 
					  state => state.challengesApp.superBlocks,
 | 
				
			||||||
 | 
					    ({ viewType }, challenge, superBlocks = []) => ({
 | 
				
			||||||
    challenge,
 | 
					    challenge,
 | 
				
			||||||
    viewType
 | 
					    viewType,
 | 
				
			||||||
 | 
					    areChallengesLoaded: superBlocks.length > 0
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -57,12 +59,15 @@ export class Challenges extends PureComponent {
 | 
				
			|||||||
    isStep: PropTypes.bool,
 | 
					    isStep: PropTypes.bool,
 | 
				
			||||||
    fetchChallenges: PropTypes.func,
 | 
					    fetchChallenges: PropTypes.func,
 | 
				
			||||||
    replaceChallenge: PropTypes.func,
 | 
					    replaceChallenge: PropTypes.func,
 | 
				
			||||||
    params: PropTypes.object
 | 
					    params: PropTypes.object,
 | 
				
			||||||
 | 
					    areChallengesLoaded: PropTypes.bool
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  componentDidMount() {
 | 
					  componentDidMount() {
 | 
				
			||||||
 | 
					    if (!this.props.areChallengesLoaded) {
 | 
				
			||||||
      this.props.fetchChallenges();
 | 
					      this.props.fetchChallenges();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  componentWillReceiveProps(nextProps) {
 | 
					  componentWillReceiveProps(nextProps) {
 | 
				
			||||||
    if (this.props.params.dashedName !== nextProps.params.dashedName) {
 | 
					    if (this.props.params.dashedName !== nextProps.params.dashedName) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user