Fix(challenges): do not load beta/comming soon challenges directly
This commit is contained in:
@ -8,10 +8,15 @@ const isBeta = !!process.env.BETA;
|
|||||||
const challengesRegex = /^(bonfire|waypoint|zipline|basejump|checkpoint)/i;
|
const challengesRegex = /^(bonfire|waypoint|zipline|basejump|checkpoint)/i;
|
||||||
const log = debug('fcc:services:map');
|
const log = debug('fcc:services:map');
|
||||||
|
|
||||||
function shouldNotFilterComingSoon({ isComingSoon, isBeta: challengeIsBeta }) {
|
// if challenge is not isComingSoon or isBeta => load
|
||||||
return isDev ||
|
// if challenge is commingSoon we are in beta||dev => load
|
||||||
!isComingSoon ||
|
// if challenge is beta and we are in beta||dev => load
|
||||||
(isBeta && challengeIsBeta);
|
// else hide
|
||||||
|
function loadComingSoonOrBetaChallenge({
|
||||||
|
isComingSoon,
|
||||||
|
isBeta: challengeIsBeta
|
||||||
|
}) {
|
||||||
|
return !(isComingSoon || challengeIsBeta) || isDev || isBeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFirstChallenge(challengeMap$) {
|
function getFirstChallenge(challengeMap$) {
|
||||||
@ -42,7 +47,7 @@ function getChallengeAndBlock(
|
|||||||
if (
|
if (
|
||||||
!block ||
|
!block ||
|
||||||
!challenge ||
|
!challenge ||
|
||||||
!shouldNotFilterComingSoon(challenge)
|
!loadComingSoonOrBetaChallenge(challenge)
|
||||||
) {
|
) {
|
||||||
return getChallengeByDashedName(
|
return getChallengeByDashedName(
|
||||||
challengeDashedName,
|
challengeDashedName,
|
||||||
@ -80,7 +85,7 @@ function getChallengeByDashedName(dashedName, challengeMap$, lang) {
|
|||||||
.map(key => challengeMap[key]);
|
.map(key => challengeMap[key]);
|
||||||
})
|
})
|
||||||
.filter(challenge => {
|
.filter(challenge => {
|
||||||
return shouldNotFilterComingSoon(challenge) &&
|
return loadComingSoonOrBetaChallenge(challenge) &&
|
||||||
testChallengeName.test(challenge.name);
|
testChallengeName.test(challenge.name);
|
||||||
})
|
})
|
||||||
.last({ defaultValue: null })
|
.last({ defaultValue: null })
|
||||||
|
Reference in New Issue
Block a user