mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-16 16:00:45 -04:00
refactor(client): stop passing around unused data (#57432)
This commit is contained in:
committed by
GitHub
parent
245b486f63
commit
3c48b8dd3f
@@ -86,6 +86,7 @@ exports.createPages = async function createPages({
|
||||
blockHashSlug
|
||||
}
|
||||
id
|
||||
isLastChallengeInBlock
|
||||
order
|
||||
required {
|
||||
link
|
||||
|
||||
@@ -219,7 +219,7 @@ export default function completionEpic(action$, state$) {
|
||||
const state = state$.value;
|
||||
|
||||
const {
|
||||
nextBlock,
|
||||
isLastChallengeInBlock,
|
||||
nextChallengePath,
|
||||
challengeType,
|
||||
superBlock,
|
||||
@@ -243,8 +243,7 @@ export default function completionEpic(action$, state$) {
|
||||
submitter = submitters[submitTypes[challengeType]];
|
||||
}
|
||||
|
||||
const lastChallengeInBlock = block !== nextBlock;
|
||||
let pathToNavigateTo = lastChallengeInBlock
|
||||
let pathToNavigateTo = isLastChallengeInBlock
|
||||
? blockHashSlug
|
||||
: nextChallengePath;
|
||||
|
||||
@@ -254,7 +253,7 @@ export default function completionEpic(action$, state$) {
|
||||
|
||||
return submitter(type, state).pipe(
|
||||
concat(
|
||||
of(setIsAdvancing(!lastChallengeInBlock), setIsProcessing(false))
|
||||
of(setIsAdvancing(!isLastChallengeInBlock), setIsProcessing(false))
|
||||
),
|
||||
mergeMap(x =>
|
||||
canAllowDonationRequest(state, x)
|
||||
|
||||
@@ -23,7 +23,7 @@ const initialState = {
|
||||
block: '',
|
||||
blockHashSlug: '/',
|
||||
id: '',
|
||||
nextBlock: '',
|
||||
isLastChallengeInBlock: false,
|
||||
nextChallengePath: '/',
|
||||
prevChallengePath: '/',
|
||||
challengeType: -1
|
||||
|
||||
@@ -86,11 +86,6 @@ function getTemplateComponent(challengeType) {
|
||||
return views[viewTypes[challengeType]];
|
||||
}
|
||||
|
||||
function getNextBlock(id, edges) {
|
||||
const next = edges[id + 1];
|
||||
return next ? next.node.challenge.block : null;
|
||||
}
|
||||
|
||||
exports.createChallengePages = function (createPage) {
|
||||
return function ({ node }, index, allChallengeEdges) {
|
||||
const {
|
||||
@@ -104,7 +99,8 @@ exports.createChallengePages = function (createPage) {
|
||||
required = [],
|
||||
template,
|
||||
challengeType,
|
||||
id
|
||||
id,
|
||||
isLastChallengeInBlock
|
||||
} = node.challenge;
|
||||
// TODO: challengeType === 7 and isPrivate are the same, right? If so, we
|
||||
// should remove one of them.
|
||||
@@ -124,7 +120,7 @@ exports.createChallengePages = function (createPage) {
|
||||
isFirstStep: getIsFirstStepInBlock(index, allChallengeEdges),
|
||||
template,
|
||||
required,
|
||||
nextBlock: getNextBlock(index, allChallengeEdges),
|
||||
isLastChallengeInBlock: isLastChallengeInBlock,
|
||||
nextChallengePath: getNextChallengePath(index, allChallengeEdges),
|
||||
prevChallengePath: getPrevChallengePath(index, allChallengeEdges),
|
||||
id
|
||||
|
||||
@@ -304,6 +304,9 @@ function generateChallengeCreator(lang, englishPath, i18nPath) {
|
||||
({ id }) => id === challenge.id
|
||||
);
|
||||
|
||||
const isLastChallengeInBlock =
|
||||
meta.challengeOrder.length - 1 === challengeOrder;
|
||||
|
||||
const isObjectIdFilename = /\/[a-z0-9]{24}\.md$/.test(englishPath);
|
||||
if (isObjectIdFilename) {
|
||||
const filename = englishPath.split('/').pop();
|
||||
@@ -348,6 +351,7 @@ function generateChallengeCreator(lang, englishPath, i18nPath) {
|
||||
challenge.certification = hasDupe ? hasDupe.certification : meta.superBlock;
|
||||
challenge.superBlock = meta.superBlock;
|
||||
challenge.challengeOrder = challengeOrder;
|
||||
challenge.isLastChallengeInBlock = isLastChallengeInBlock;
|
||||
challenge.isPrivate = challenge.isPrivate || meta.isPrivate;
|
||||
challenge.required = (meta.required || []).concat(challenge.required || []);
|
||||
challenge.template = meta.template;
|
||||
|
||||
@@ -180,6 +180,7 @@ const schema = Joi.object()
|
||||
'Euler',
|
||||
'Rosetta'
|
||||
),
|
||||
isLastChallengeInBlock: Joi.boolean().required(),
|
||||
videoUrl: Joi.string().allow(''),
|
||||
fillInTheBlank: Joi.object().keys({
|
||||
sentence: Joi.string().required(),
|
||||
|
||||
Reference in New Issue
Block a user