fix: allow claiming rewards with multiple of the same type
This commit is contained in:
parent
1627e26525
commit
cb47ccb925
3 changed files with 17 additions and 3 deletions
9
dist/bundle.js
vendored
9
dist/bundle.js
vendored
|
@ -8036,6 +8036,10 @@ function doClaimRewardType(rewardType) {
|
|||
error: !options || !options.failSilently ? error : undefined
|
||||
}
|
||||
});
|
||||
|
||||
if (options.notifyError) {
|
||||
dispatch((0, _lbryRedux.doError)(error.message));
|
||||
}
|
||||
};
|
||||
|
||||
_rewards3.default.claimReward(rewardType, options.params).then(success, failure);
|
||||
|
@ -9075,6 +9079,9 @@ function setClaimRewardState(state, reward, isClaiming) {
|
|||
|
||||
var newClaimPendingByType = Object.assign({}, state.claimPendingByType);
|
||||
var newClaimErrorsByType = Object.assign({}, state.claimErrorsByType);
|
||||
|
||||
// Currently, for multiple rewards of the same type, they will both show "claiming" when one is beacuse we track this by `reward_type`
|
||||
// To fix this we will need to use `claim_code` instead, and change all selectors to match
|
||||
if (isClaiming) {
|
||||
newClaimPendingByType[reward.reward_type] = isClaiming;
|
||||
} else {
|
||||
|
@ -9105,7 +9112,7 @@ reducers[_lbryRedux.ACTIONS.CLAIM_REWARD_SUCCESS] = function (state, action) {
|
|||
|
||||
|
||||
var index = unclaimedRewards.findIndex(function (ur) {
|
||||
return ur.reward_type === reward.reward_type;
|
||||
return ur.claim_code === reward.claim_code;
|
||||
});
|
||||
unclaimedRewards.splice(index, 1);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Lbryio from 'lbryio';
|
||||
import { ACTIONS } from 'lbry-redux';
|
||||
import { ACTIONS, doError } from 'lbry-redux';
|
||||
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
|
||||
import { selectUserIsRewardApproved } from 'redux/selectors/user';
|
||||
import rewards from 'rewards';
|
||||
|
@ -81,6 +81,10 @@ export function doClaimRewardType(rewardType, options = {}) {
|
|||
error: !options || !options.failSilently ? error : undefined,
|
||||
},
|
||||
});
|
||||
|
||||
if (options.notifyError) {
|
||||
dispatch(doError(error.message));
|
||||
}
|
||||
};
|
||||
|
||||
rewards.claimReward(rewardType, options.params).then(success, failure);
|
||||
|
|
|
@ -38,6 +38,9 @@ reducers[ACTIONS.FETCH_REWARDS_COMPLETED] = (state, action) => {
|
|||
function setClaimRewardState(state, reward, isClaiming, errorMessage = '') {
|
||||
const newClaimPendingByType = Object.assign({}, state.claimPendingByType);
|
||||
const newClaimErrorsByType = Object.assign({}, state.claimErrorsByType);
|
||||
|
||||
// Currently, for multiple rewards of the same type, they will both show "claiming" when one is beacuse we track this by `reward_type`
|
||||
// To fix this we will need to use `claim_code` instead, and change all selectors to match
|
||||
if (isClaiming) {
|
||||
newClaimPendingByType[reward.reward_type] = isClaiming;
|
||||
} else {
|
||||
|
@ -65,7 +68,7 @@ reducers[ACTIONS.CLAIM_REWARD_SUCCESS] = (state, action) => {
|
|||
const { reward } = action.data;
|
||||
const { unclaimedRewards } = state;
|
||||
|
||||
const index = unclaimedRewards.findIndex(ur => ur.reward_type === reward.reward_type);
|
||||
const index = unclaimedRewards.findIndex(ur => ur.claim_code === reward.claim_code);
|
||||
unclaimedRewards.splice(index, 1);
|
||||
|
||||
const { claimedRewardsById } = state;
|
||||
|
|
Loading…
Reference in a new issue