refactor: files{} -> challengeFiles[], and key -> fileKey (#43023)
* fix(client): fix client * fix propType and add comment * revert user.json prettification * slight type refactor and payload correction Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * update ChallengeFile type imports * add cypress test for code-storage * update test and storage epic * fix Shaun's tired brain's logic * refactor with suggestions Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * update codeReset * increate cypress timeout because firefox is slow * remove unused import to make linter happy * use focus on editor Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * use more specific seletor for cypress editor test * account for silly null challengeFiles Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -17,19 +17,19 @@ exports.translateComments = (text, lang, dict, codeLang) => {
|
||||
|
||||
exports.translateCommentsInChallenge = (challenge, lang, dict) => {
|
||||
const challClone = cloneDeep(challenge);
|
||||
if (!challClone.files) {
|
||||
if (!challClone.challengeFiles) {
|
||||
console.warn(`Challenge ${challClone.title} has no seed to translate`);
|
||||
} else {
|
||||
Object.keys(challClone.files).forEach(key => {
|
||||
if (challClone.files[key].contents) {
|
||||
challClone.challengeFiles.forEach(challengeFile => {
|
||||
if (challengeFile.contents) {
|
||||
let { text, commentCounts } = this.translateComments(
|
||||
challenge.files[key].contents,
|
||||
challengeFile.contents,
|
||||
lang,
|
||||
dict,
|
||||
challClone.files[key].ext
|
||||
challengeFile.ext
|
||||
);
|
||||
challClone.__commentCounts = commentCounts;
|
||||
challClone.files[key].contents = text;
|
||||
challengeFile.contents = text;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user