fix(nextChallenge): Remove some duplication

This commit is contained in:
Stuart Taylor
2018-02-24 08:44:12 +00:00
parent b27036a261
commit 329438bdf4
5 changed files with 102 additions and 137 deletions

View File

@@ -28,22 +28,22 @@ export default function getChallengesForBlock(app) {
}
}) => {
log(`sourcing challenges for the ${blockName} block`);
const requestedChallenges = pickBy(
challengeMap,
ch => ch.block === blockName
);
const entities = {
block: {
[blockName]: fullBlockMap[blockName]
},
challenge: requestedChallenges
};
const { challenge, block } = shapeChallenges(entities, isDev);
return Observable.of({
result: { superBlocks },
entities: { challenge, block }
});
const requestedChallenges = pickBy(
challengeMap,
ch => ch.block === blockName
);
const entities = {
block: {
[blockName]: fullBlockMap[blockName]
},
challenge: requestedChallenges
};
const { challenge, block } = shapeChallenges(entities, isDev);
return Observable.of({
result: { superBlocks },
entities: { challenge, block }
});
});
return Observable.if(
() => !!dashedName,
getChallenge(dashedName, blockName, challengeMap, lang),