fix merge conflicts

This commit is contained in:
Akinwale Ariwodola 2019-02-15 09:55:24 +01:00
commit 7f690b89ac
7 changed files with 623 additions and 510 deletions

1063
dist/bundle.js vendored

File diff suppressed because it is too large Load diff

View file

@ -42,6 +42,7 @@ export {
doAuthenticate,
doUserFetch,
doUserEmailNew,
doUserCheckEmailVerified,
doUserEmailToVerify,
doUserEmailVerifyFailure,
doUserEmailVerify,
@ -81,6 +82,7 @@ export {
selectClaimRewardError,
selectRewardByType,
selectRewardContentClaimIds,
selectReferralReward,
} from 'redux/selectors/rewards';
export {
makeSelectIsNew,

View file

@ -115,12 +115,12 @@ Lbryio.authenticate = () => {
// check that token works
return Lbryio.getCurrentUser()
.then(() => true)
.then(user => user)
.catch(() => false);
})
.then(isTokenValid => {
if (isTokenValid) {
return reject;
.then(user => {
if (user) {
return user;
}
return Lbry.status().then(status => {
@ -137,7 +137,12 @@ Lbryio.authenticate = () => {
return reject();
});
})
.then(Lbryio.getCurrentUser)
.then(user => {
if (!user) {
return Lbryio.getCurrentUser();
}
return user;
})
.then(resolve, reject);
});
}

View file

@ -1,7 +1,8 @@
import Lbryio from 'lbryio';
import { ACTIONS } from 'lbry-redux';
import { ACTIONS, doToast } from 'lbry-redux';
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
import { selectUserIsRewardApproved } from 'redux/selectors/user';
import { doFetchInviteStatus } from 'redux/actions/user';
import rewards from 'rewards';
export function doRewardList() {
@ -51,6 +52,10 @@ export function doClaimRewardType(rewardType, options = {}) {
return;
}
// Set `claim_code` so the api knows which reward to give if there are multiple of the same type
const params = options.params || {};
params.claim_code = reward.claim_code;
dispatch({
type: ACTIONS.CLAIM_REWARD_STARTED,
data: { reward },
@ -68,6 +73,8 @@ export function doClaimRewardType(rewardType, options = {}) {
rewards.callbacks.claimFirstRewardSuccess
) {
rewards.callbacks.claimFirstRewardSuccess();
} else if (successReward.reward_type === rewards.TYPE_REFERRAL) {
dispatch(doFetchInviteStatus());
}
dispatch(doRewardList());
@ -81,9 +88,13 @@ export function doClaimRewardType(rewardType, options = {}) {
error: !options || !options.failSilently ? error : undefined,
},
});
if (options.notifyError) {
dispatch(doToast({ message: error.message, isError: true }));
}
};
rewards.claimReward(rewardType, options.params).then(success, failure);
rewards.claimReward(rewardType, params).then(success, failure);
};
}

View file

@ -16,6 +16,8 @@ export function doFetchInviteStatus() {
Lbryio.call('user', 'invite_status')
.then(status => {
dispatch(doRewardList());
dispatch({
type: ACTIONS.USER_INVITE_STATUS_FETCH_SUCCESS,
data: {
@ -98,6 +100,22 @@ export function doUserFetch() {
};
}
export function doUserCheckEmailVerified() {
// This will happen in the background so we don't need loading booleans
return dispatch => {
Lbryio.getCurrentUser().then(user => {
if (user.has_verified_email) {
dispatch(doRewardList());
dispatch({
type: ACTIONS.USER_FETCH_SUCCESS,
data: { user },
});
}
});
};
}
export function doUserPhoneReset() {
return {
type: ACTIONS.USER_PHONE_RESET,

View file

@ -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;

View file

@ -1,4 +1,5 @@
import { createSelector } from 'reselect';
import REWARDS from 'rewards';
const selectState = state => state.rewards || {};
@ -67,3 +68,9 @@ export const selectRewardContentClaimIds = createSelector(
selectState,
state => state.rewardedContentClaimIds
);
export const selectReferralReward = createSelector(
selectUnclaimedRewards,
unclaimedRewards =>
unclaimedRewards.filter(reward => reward.reward_type === REWARDS.TYPE_REFERRAL)[0]
);