use splice to remove reward; force update in newState data
This commit is contained in:
parent
186c437955
commit
cb85b633f7
1 changed files with 4 additions and 4 deletions
|
@ -62,18 +62,18 @@ reducers[ACTIONS.CLAIM_REWARD_STARTED] = (state, action) => {
|
|||
|
||||
reducers[ACTIONS.CLAIM_REWARD_SUCCESS] = (state, action) => {
|
||||
const { reward } = action.data;
|
||||
let { unclaimedRewards } = state;
|
||||
const { unclaimedRewards } = state;
|
||||
|
||||
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;
|
||||
claimedRewardsById[reward.id] = reward;
|
||||
|
||||
const newState = {
|
||||
...state,
|
||||
unclaimedRewards,
|
||||
claimedRewardsById,
|
||||
unclaimedRewards: [...unclaimedRewards],
|
||||
claimedRewardsById: { ...claimedRewardsById },
|
||||
};
|
||||
|
||||
return setClaimRewardState(newState, reward, false, '');
|
||||
|
|
Loading…
Add table
Reference in a new issue