mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-03 20:35:17 +00:00
Merge pull request #2206 from lbryio/rewards-fix
Fix: Allow multiple rewards of same type to be claimed and remove reward error modal
This commit is contained in:
commit
50028e4d9b
9 changed files with 15 additions and 51 deletions
|
@ -53,7 +53,7 @@
|
||||||
"keytar": "^4.2.1",
|
"keytar": "^4.2.1",
|
||||||
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
||||||
"lbry-redux": "lbryio/lbry-redux#a22f8284110f957f3f645d42abc457ab8fb3fa8a",
|
"lbry-redux": "lbryio/lbry-redux#a22f8284110f957f3f645d42abc457ab8fb3fa8a",
|
||||||
"lbryinc": "lbryio/lbryinc#b3bb8c67745235ef54baea95accaedaa4bb86d4d",
|
"lbryinc": "lbryio/lbryinc#83c275da7a44f346ce9e796d06f30126f02b4c63",
|
||||||
"localforage": "^1.7.1",
|
"localforage": "^1.7.1",
|
||||||
"mammoth": "^1.4.6",
|
"mammoth": "^1.4.6",
|
||||||
"mime": "^2.3.1",
|
"mime": "^2.3.1",
|
||||||
|
|
|
@ -1,35 +1,19 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import {
|
import { makeSelectRewardByType, makeSelectIsRewardClaimPending, doClaimRewardType } from 'lbryinc';
|
||||||
makeSelectClaimRewardError,
|
|
||||||
makeSelectRewardByType,
|
|
||||||
makeSelectIsRewardClaimPending,
|
|
||||||
doClaimRewardType,
|
|
||||||
doClaimRewardClearError,
|
|
||||||
} from 'lbryinc';
|
|
||||||
import { doNavigate } from 'redux/actions/navigation';
|
import { doNavigate } from 'redux/actions/navigation';
|
||||||
import RewardLink from './view';
|
import RewardLink from './view';
|
||||||
|
|
||||||
const makeSelect = () => {
|
const select = (state, props) => ({
|
||||||
const selectIsPending = makeSelectIsRewardClaimPending();
|
isPending: makeSelectIsRewardClaimPending()(state, props),
|
||||||
const selectReward = makeSelectRewardByType();
|
reward: makeSelectRewardByType()(state, props.reward_type),
|
||||||
const selectError = makeSelectClaimRewardError();
|
});
|
||||||
|
|
||||||
const select = (state, props) => ({
|
|
||||||
errorMessage: selectError(state, props),
|
|
||||||
isPending: selectIsPending(state, props),
|
|
||||||
reward: selectReward(state, props.reward_type),
|
|
||||||
});
|
|
||||||
|
|
||||||
return select;
|
|
||||||
};
|
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
claimReward: reward => dispatch(doClaimRewardType(reward.reward_type)),
|
claimReward: reward => dispatch(doClaimRewardType(reward.reward_type, { notifyError: true })),
|
||||||
clearError: reward => dispatch(doClaimRewardClearError(reward)),
|
|
||||||
navigate: path => dispatch(doNavigate(path)),
|
navigate: path => dispatch(doNavigate(path)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
makeSelect,
|
select,
|
||||||
perform
|
perform
|
||||||
)(RewardLink);
|
)(RewardLink);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Modal } from 'modal/modal';
|
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
|
|
||||||
type Reward = {
|
type Reward = {
|
||||||
|
@ -10,15 +9,13 @@ type Reward = {
|
||||||
type Props = {
|
type Props = {
|
||||||
isPending: boolean,
|
isPending: boolean,
|
||||||
label: ?string,
|
label: ?string,
|
||||||
errorMessage: ?string,
|
|
||||||
reward: Reward,
|
reward: Reward,
|
||||||
button: ?boolean,
|
button: ?boolean,
|
||||||
clearError: Reward => void,
|
|
||||||
claimReward: Reward => void,
|
claimReward: Reward => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
const RewardLink = (props: Props) => {
|
const RewardLink = (props: Props) => {
|
||||||
const { reward, claimReward, clearError, errorMessage, label, isPending, button } = props;
|
const { reward, claimReward, label, isPending, button } = props;
|
||||||
|
|
||||||
return !reward ? null : (
|
return !reward ? null : (
|
||||||
<div className="reward-link">
|
<div className="reward-link">
|
||||||
|
@ -30,23 +27,6 @@ const RewardLink = (props: Props) => {
|
||||||
claimReward(reward);
|
claimReward(reward);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errorMessage ? (
|
|
||||||
// TODO: This should be moved to redux
|
|
||||||
<Modal
|
|
||||||
isOpen
|
|
||||||
title={__('Error Claiming Reward')}
|
|
||||||
contentLabel="Reward Claim Error"
|
|
||||||
onConfirmed={() => {
|
|
||||||
clearError(reward);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<section className="card__content">
|
|
||||||
<div className="error-modal__error-list">{errorMessage}</div>
|
|
||||||
</section>
|
|
||||||
</Modal>
|
|
||||||
) : (
|
|
||||||
''
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,7 +51,6 @@ class UserEmailNew extends React.PureComponent<Props, State> {
|
||||||
'In addition, your email address will never be sold and you can unsubscribe at any time.'
|
'In addition, your email address will never be sold and you can unsubscribe at any time.'
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<Form onSubmit={this.handleSubmit}>
|
<Form onSubmit={this.handleSubmit}>
|
||||||
<FormRow>
|
<FormRow>
|
||||||
<FormField
|
<FormField
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ModalFirstReward extends React.PureComponent<Props> {
|
||||||
<p>{__('You just earned your first reward!')}</p>
|
<p>{__('You just earned your first reward!')}</p>
|
||||||
<p>
|
<p>
|
||||||
{__(
|
{__(
|
||||||
"This reward will show in your Wallet in the top right momentarily (if it hasn't already)."
|
"This reward will show in your Wallet in the top left momentarily (if it hasn't already)."
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -152,7 +152,7 @@ class RewardsPage extends PureComponent<Props> {
|
||||||
'card--disabled': isNotEligible,
|
'card--disabled': isNotEligible,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{rewards.map(reward => <RewardTile key={reward.reward_type} reward={reward} />)}
|
{rewards.map(reward => <RewardTile key={reward.claim_code} reward={reward} />)}
|
||||||
{this.renderCustomRewardCode()}
|
{this.renderCustomRewardCode()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
.card__content {
|
.card__content {
|
||||||
font-size: 1.15rem;
|
font-size: 1.15rem;
|
||||||
|
|
||||||
p:not(:last-of-type) {
|
p:not(:last-child) {
|
||||||
margin-bottom: var(--spacing-vertical-medium);
|
margin-bottom: var(--spacing-vertical-medium);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,5 @@ export type Reward = {
|
||||||
reward_version: ?string,
|
reward_version: ?string,
|
||||||
transaction_id: ?string,
|
transaction_id: ?string,
|
||||||
updated_at: ?string,
|
updated_at: ?string,
|
||||||
|
claim_code: string,
|
||||||
};
|
};
|
||||||
|
|
|
@ -5698,9 +5698,9 @@ lbry-redux@lbryio/lbry-redux#a22f8284110f957f3f645d42abc457ab8fb3fa8a:
|
||||||
reselect "^3.0.0"
|
reselect "^3.0.0"
|
||||||
uuid "^3.3.2"
|
uuid "^3.3.2"
|
||||||
|
|
||||||
lbryinc@lbryio/lbryinc#b3bb8c67745235ef54baea95accaedaa4bb86d4d:
|
lbryinc@lbryio/lbryinc#83c275da7a44f346ce9e796d06f30126f02b4c63:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/b3bb8c67745235ef54baea95accaedaa4bb86d4d"
|
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/83c275da7a44f346ce9e796d06f30126f02b4c63"
|
||||||
dependencies:
|
dependencies:
|
||||||
lbry-redux lbryio/lbry-redux#84b7d396934d57a37802aadbef71db91230a9404
|
lbry-redux lbryio/lbry-redux#84b7d396934d57a37802aadbef71db91230a9404
|
||||||
reselect "^3.0.0"
|
reselect "^3.0.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue