mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
refactor(client): speed up client updates (#65025)
This commit is contained in:
committed by
GitHub
parent
d6d452dfac
commit
e6eb338fe6
@@ -51,7 +51,6 @@ exports.replaceChallengeNodes = () => {
|
||||
const block = path.basename(parentDir);
|
||||
const filename = path.basename(filePath);
|
||||
|
||||
console.log(`Replacing challenge nodes for ${filePath}`);
|
||||
const meta = getBlockStructure(block);
|
||||
const superblocks = getSuperblocks(block);
|
||||
|
||||
|
||||
@@ -69,23 +69,25 @@ const views = {
|
||||
examDownload
|
||||
};
|
||||
|
||||
function getIsFirstStepInBlock(id, edges) {
|
||||
const current = edges[id];
|
||||
const previous = edges[id - 1];
|
||||
function getIsFirstStepInBlock(id, nodes) {
|
||||
const current = nodes[id];
|
||||
const previous = nodes[id - 1];
|
||||
|
||||
if (!previous) return true;
|
||||
return previous.node.challenge.block !== current.node.challenge.block;
|
||||
return previous.challenge.block !== current.challenge.block;
|
||||
}
|
||||
|
||||
function getTemplateComponent(challengeType) {
|
||||
return views[viewTypes[challengeType]];
|
||||
}
|
||||
|
||||
exports.getTemplateComponent = getTemplateComponent;
|
||||
|
||||
exports.createChallengePages = function (
|
||||
createPage,
|
||||
{ idToNextPathCurrentCurriculum, idToPrevPathCurrentCurriculum }
|
||||
) {
|
||||
return function ({ node }, index, allChallengeEdges) {
|
||||
return function (node, index, allChallengeNodes) {
|
||||
const {
|
||||
dashedName,
|
||||
disableLoopProtectTests,
|
||||
@@ -118,7 +120,7 @@ exports.createChallengePages = function (
|
||||
chapter,
|
||||
module,
|
||||
block,
|
||||
isFirstStep: getIsFirstStepInBlock(index, allChallengeEdges),
|
||||
isFirstStep: getIsFirstStepInBlock(index, allChallengeNodes),
|
||||
template,
|
||||
required,
|
||||
isLastChallengeInBlock: isLastChallengeInBlock,
|
||||
@@ -129,7 +131,7 @@ exports.createChallengePages = function (
|
||||
},
|
||||
projectPreview: getProjectPreviewConfig(
|
||||
node.challenge,
|
||||
allChallengeEdges
|
||||
allChallengeNodes
|
||||
),
|
||||
id: node.id
|
||||
}
|
||||
@@ -140,12 +142,12 @@ exports.createChallengePages = function (
|
||||
// TODO: figure out a cleaner way to get the last challenge in a block. Create
|
||||
// it during the curriculum build process and attach it to the first challenge?
|
||||
// That would remove the need to analyse allChallengeEdges.
|
||||
function getProjectPreviewConfig(challenge, allChallengeEdges) {
|
||||
function getProjectPreviewConfig(challenge, allChallengeNodes) {
|
||||
const { block } = challenge;
|
||||
|
||||
const challengesInBlock = allChallengeEdges
|
||||
.filter(({ node: { challenge } }) => challenge.block === block)
|
||||
.map(({ node: { challenge } }) => challenge);
|
||||
const challengesInBlock = allChallengeNodes
|
||||
.filter(({ challenge }) => challenge.block === block)
|
||||
.map(({ challenge }) => challenge);
|
||||
const lastChallenge = challengesInBlock[challengesInBlock.length - 1];
|
||||
const solutionFiles = lastChallenge.solutions[0] ?? [];
|
||||
const lastChallengeFiles = lastChallenge.challengeFiles ?? [];
|
||||
|
||||
Reference in New Issue
Block a user