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 { return {
...state, ...state,
challengeFiles: [ challengeFiles: state.challengeFiles.map(challengeFile =>
...state.challengeFiles.filter(x => x.fileKey !== fileKey), challengeFile.fileKey === fileKey
{ ? { ...challengeFile, ...updates }
...state.challengeFiles.find(x => x.fileKey === fileKey), : { ...challengeFile }
...updates )
}
]
}; };
}, },
[actionTypes.storedCodeFound]: (state, { payload }) => ({ [actionTypes.storedCodeFound]: (state, { payload }) => ({