fix(client): keep challengeFile order on update (#44722)

* fix: keep challengeFile order on update

* refactor: name variable challengeFile, not file

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>

* fix: prettify

Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
Oliver Eyton-Williams
2022-01-10 23:02:30 +01:00
committed by GitHub
parent 54317be92f
commit 2952f9399d

View File

@ -231,13 +231,11 @@ export const reducer = handleActions(
);
return {
...state,
challengeFiles: [
...state.challengeFiles.filter(x => x.fileKey !== fileKey),
{
...state.challengeFiles.find(x => x.fileKey === fileKey),
...updates
}
]
challengeFiles: state.challengeFiles.map(challengeFile =>
challengeFile.fileKey === fileKey
? { ...challengeFile, ...updates }
: { ...challengeFile }
)
};
},
[actionTypes.storedCodeFound]: (state, { payload }) => ({