fix(client): use source head/tail if challenge is saved (#55596)

This commit is contained in:
Oliver Eyton-Williams 2024-07-22 18:54:16 +02:00 committed by GitHub
parent 2610a39539
commit 2f59fee0c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View File

@ -176,11 +176,11 @@ const defaultOutput = `
*/`;
function ShowClassic({
challengeFiles: reduxChallengeFiles,
challengeFiles,
data: {
challengeNode: {
challenge: {
challengeFiles,
challengeFiles: seedChallengeFiles,
block,
title,
description,
@ -363,7 +363,7 @@ function ShowClassic({
});
createFiles(
mergeChallengeFiles(challengeFiles, savedChallenge?.challengeFiles)
mergeChallengeFiles(seedChallengeFiles, savedChallenge?.challengeFiles)
);
initTests(tests);
@ -416,9 +416,9 @@ function ShowClassic({
isUsingKeyboardInTablist
}: RenderEditorArgs) => {
return (
reduxChallengeFiles && (
challengeFiles && (
<MultifileEditor
challengeFiles={reduxChallengeFiles}
challengeFiles={challengeFiles}
block={block}
superBlock={superBlock}
containerRef={containerRef}
@ -482,7 +482,7 @@ function ShowClassic({
)}
{!isMobile && (
<DesktopLayout
challengeFiles={reduxChallengeFiles}
challengeFiles={challengeFiles}
challengeType={challengeType}
editor={renderEditor({
isMobileLayout: false,

View File

@ -2,6 +2,7 @@ import { isEmpty } from 'lodash-es';
import { handleActions } from 'redux-actions';
import { getLines } from '../../../../../shared/utils/get-lines';
import { mergeChallengeFiles } from '../classic/saved-challenges';
import { getTargetEditor } from '../utils/get-target-editor';
import { actionTypes, ns } from './action-types';
import codeStorageEpic from './code-storage-epic';
@ -110,7 +111,9 @@ export const reducer = handleActions(
},
[actionTypes.storedCodeFound]: (state, { payload }) => ({
...state,
challengeFiles: payload
challengeFiles: state.challengeFiles.length
? mergeChallengeFiles(state.challengeFiles, payload)
: payload
}),
[actionTypes.initTests]: (state, { payload }) => ({
...state,