use splice to remove reward; force update in newState data

This commit is contained in:
Travis Eden 2018-05-30 12:09:01 -04:00
parent 186c437955
commit cb85b633f7

View file

@ -62,18 +62,18 @@ reducers[ACTIONS.CLAIM_REWARD_STARTED] = (state, action) => {
reducers[ACTIONS.CLAIM_REWARD_SUCCESS] = (state, action) => { reducers[ACTIONS.CLAIM_REWARD_SUCCESS] = (state, action) => {
const { reward } = action.data; const { reward } = action.data;
let { unclaimedRewards } = state; const { unclaimedRewards } = state;
const index = unclaimedRewards.findIndex(ur => ur.reward_type === reward.reward_type); const index = unclaimedRewards.findIndex(ur => ur.reward_type === reward.reward_type);
unclaimedRewards = unclaimedRewards.slice(0, index).concat(unclaimedRewards.slice(index + 1)); unclaimedRewards.splice(index, 1);
const { claimedRewardsById } = state; const { claimedRewardsById } = state;
claimedRewardsById[reward.id] = reward; claimedRewardsById[reward.id] = reward;
const newState = { const newState = {
...state, ...state,
unclaimedRewards, unclaimedRewards: [...unclaimedRewards],
claimedRewardsById, claimedRewardsById: { ...claimedRewardsById },
}; };
return setClaimRewardState(newState, reward, false, ''); return setClaimRewardState(newState, reward, false, '');