fix(client): allow old local-storage code (#43196)
This commit is contained in:
@ -60,9 +60,15 @@ function legacyToFile(code, challengeFiles, fileKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isFilesAllPoly(challengeFiles) {
|
function isFilesAllPoly(challengeFiles) {
|
||||||
// TODO: figure out how challengeFiles might be null/not have .every as a
|
if (Array.isArray(challengeFiles)) {
|
||||||
// function
|
return challengeFiles?.every(file => isPoly(file));
|
||||||
return challengeFiles?.every(file => isPoly(file));
|
} else {
|
||||||
|
// TODO: After sufficient time, remove parsing of old code-storage format
|
||||||
|
// This was pushed to production with https://github.com/freeCodeCamp/freeCodeCamp/pull/43023
|
||||||
|
return Object.keys(challengeFiles)
|
||||||
|
.map(key => challengeFiles[key])
|
||||||
|
.every(file => isPoly(file));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearCodeEpic(action$, state$) {
|
function clearCodeEpic(action$, state$) {
|
||||||
@ -134,9 +140,16 @@ function loadCodeEpic(action$, state$) {
|
|||||||
const codeFound = getCode(id);
|
const codeFound = getCode(id);
|
||||||
if (codeFound && isFilesAllPoly(codeFound)) {
|
if (codeFound && isFilesAllPoly(codeFound)) {
|
||||||
finalFiles = challengeFiles.reduce((challengeFiles, challengeFile) => {
|
finalFiles = challengeFiles.reduce((challengeFiles, challengeFile) => {
|
||||||
const foundChallengeFile = codeFound.find(
|
let foundChallengeFile = {};
|
||||||
x => x.fileKey === challengeFile.fileKey
|
if (Array.isArray(codeFound)) {
|
||||||
);
|
foundChallengeFile = codeFound.find(
|
||||||
|
x => x.fileKey === challengeFile.fileKey
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// TODO: After sufficient time, remove parsing of old code-storage format
|
||||||
|
// This was pushed to production with https://github.com/freeCodeCamp/freeCodeCamp/pull/43023
|
||||||
|
foundChallengeFile = codeFound[challengeFile.fileKey];
|
||||||
|
}
|
||||||
const isCodeFound = Object.keys(foundChallengeFile).length > 0;
|
const isCodeFound = Object.keys(foundChallengeFile).length > 0;
|
||||||
return [
|
return [
|
||||||
...challengeFiles,
|
...challengeFiles,
|
||||||
|
Reference in New Issue
Block a user