From 0326d12175fbd3c7a2574cc0ecbc24fd89c710ef Mon Sep 17 00:00:00 2001 From: Stuart Taylor Date: Sun, 3 Jun 2018 20:30:26 +0100 Subject: [PATCH] fix(typo): Fixes typo the made the local completedChallenges array unusable (#142) --- packages/learn/src/redux/app/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/learn/src/redux/app/index.js b/packages/learn/src/redux/app/index.js index 2cabf091b8..17bf523338 100644 --- a/packages/learn/src/redux/app/index.js +++ b/packages/learn/src/redux/app/index.js @@ -1,4 +1,5 @@ import { createAction, handleActions } from 'redux-actions'; +import { uniqBy } from 'lodash'; import { createTypes } from '../../../utils/stateManagment'; import { types as challenge } from '../../templates/Challenges/redux'; @@ -72,14 +73,14 @@ export const reducer = handleActions( ...state, isSignedIn: payload }), - [challenge.submitComplete]: (state, { payload: { points, id } }) => ({ + [challenge.submitComplete]: (state, { payload: { id } }) => ({ ...state, user: { ...state.user, - completedChallenges: - points === state.user.points - ? state.user.completedChallenges - : [...state.user.completedChallengesSelector, { id }] + completedChallenges: uniqBy( + [...state.user.completedChallenges, { id }], + 'id' + ) } }) },