diff --git a/ui/js/actions/rewards.js b/ui/js/actions/rewards.js
index 95ae3b25b..227ab7a4a 100644
--- a/ui/js/actions/rewards.js
+++ b/ui/js/actions/rewards.js
@@ -2,7 +2,7 @@ import * as types from "constants/action_types";
import * as modals from "constants/modal_types";
import lbryio from "lbryio";
import rewards from "rewards";
-import { selectRewardsByType } from "selectors/rewards";
+import { selectUnclaimedRewardsByType } from "selectors/rewards";
export function doRewardList() {
return function(dispatch, getState) {
@@ -13,7 +13,7 @@ export function doRewardList() {
});
lbryio
- .call("reward", "list", {})
+ .call("reward", "list", { multiple_rewards_per_type: true })
.then(userRewards => {
dispatch({
type: types.FETCH_REWARDS_COMPLETED,
@@ -31,17 +31,9 @@ export function doRewardList() {
export function doClaimRewardType(rewardType) {
return function(dispatch, getState) {
- const rewardsByType = selectRewardsByType(getState()),
+ const rewardsByType = selectUnclaimedRewardsByType(getState()),
reward = rewardsByType[rewardType];
- if (reward) {
- dispatch(doClaimReward(reward));
- }
- };
-}
-
-export function doClaimReward(reward, saveError = false) {
- return function(dispatch, getState) {
if (reward.transaction_id) {
//already claimed, do nothing
return;
@@ -72,7 +64,7 @@ export function doClaimReward(reward, saveError = false) {
type: types.CLAIM_REWARD_FAILURE,
data: {
reward,
- error: saveError ? error : null,
+ error: error ? error : null,
},
});
};
@@ -87,26 +79,18 @@ export function doClaimEligiblePurchaseRewards() {
return;
}
- const rewardsByType = selectRewardsByType(getState());
+ const rewardsByType = selectUnclaimedRewardsByType(getState());
- let types = {};
-
- types[rewards.TYPE_FIRST_STREAM] = false;
- types[rewards.TYPE_FEATURED_DOWNLOAD] = false;
- types[rewards.TYPE_MANY_DOWNLOADS] = false;
- Object.values(rewardsByType).forEach(reward => {
- if (types[reward.reward_type] === false && reward.transaction_id) {
- types[reward.reward_type] = true;
- }
- });
-
- let unclaimedType = Object.keys(types).find(type => {
- return types[type] === false && type !== rewards.TYPE_FEATURED_DOWNLOAD; //handled below
- });
- if (unclaimedType) {
- dispatch(doClaimRewardType(unclaimedType));
+ if (rewardsByType[rewards.TYPE_FIRST_STREAM]) {
+ dispatch(doClaimRewardType(rewards.TYPE_FIRST_STREAM));
+ } else {
+ [
+ rewards.TYPE_MANY_DOWNLOADS,
+ rewards.TYPE_FEATURED_DOWNLOAD,
+ ].forEach(type => {
+ dispatch(doClaimRewardType(type));
+ });
}
- dispatch(doClaimRewardType(rewards.TYPE_FEATURED_DOWNLOAD));
};
}
diff --git a/ui/js/component/linkTransaction/index.js b/ui/js/component/linkTransaction/index.js
new file mode 100644
index 000000000..601927420
--- /dev/null
+++ b/ui/js/component/linkTransaction/index.js
@@ -0,0 +1,5 @@
+import React from "react";
+import { connect } from "react-redux";
+import Link from "./view";
+
+export default connect(null, null)(Link);
diff --git a/ui/js/component/linkTransaction/view.jsx b/ui/js/component/linkTransaction/view.jsx
new file mode 100644
index 000000000..e1fe32159
--- /dev/null
+++ b/ui/js/component/linkTransaction/view.jsx
@@ -0,0 +1,14 @@
+import React from "react";
+import Link from "component/link";
+
+const LinkTransaction = props => {
+ const { id } = props;
+ const linkProps = Object.assign({}, props);
+
+ linkProps.href = "https://explorer.lbry.io/#!/transaction/" + id;
+ linkProps.label = id.substr(0, 7);
+
+ return ;
+};
+
+export default LinkTransaction;
diff --git a/ui/js/component/rewardLink/index.js b/ui/js/component/rewardLink/index.js
index cf53b2367..3375fbfdf 100644
--- a/ui/js/component/rewardLink/index.js
+++ b/ui/js/component/rewardLink/index.js
@@ -6,7 +6,7 @@ import {
makeSelectIsRewardClaimPending,
} from "selectors/rewards";
import { doNavigate } from "actions/app";
-import { doClaimReward, doClaimRewardClearError } from "actions/rewards";
+import { doClaimRewardType, doClaimRewardClearError } from "actions/rewards";
import RewardLink from "./view";
const makeSelect = () => {
@@ -24,7 +24,7 @@ const makeSelect = () => {
};
const perform = dispatch => ({
- claimReward: reward => dispatch(doClaimReward(reward, true)),
+ claimReward: reward => dispatch(doClaimRewardType(reward.reward_type, true)),
clearError: reward => dispatch(doClaimRewardClearError(reward)),
navigate: path => dispatch(doNavigate(path)),
});
diff --git a/ui/js/component/rewardListClaimed/index.js b/ui/js/component/rewardListClaimed/index.js
new file mode 100644
index 000000000..095121cad
--- /dev/null
+++ b/ui/js/component/rewardListClaimed/index.js
@@ -0,0 +1,10 @@
+import React from "react";
+import { connect } from "react-redux";
+import { selectClaimedRewards } from "selectors/rewards";
+import RewardListClaimed from "./view";
+
+const select = state => ({
+ rewards: selectClaimedRewards(state),
+});
+
+export default connect(select, null)(RewardListClaimed);
diff --git a/ui/js/component/rewardListClaimed/view.jsx b/ui/js/component/rewardListClaimed/view.jsx
new file mode 100644
index 000000000..f568348cd
--- /dev/null
+++ b/ui/js/component/rewardListClaimed/view.jsx
@@ -0,0 +1,44 @@
+import React from "react";
+import LinkTransaction from "component/linkTransaction";
+
+const RewardListClaimed = props => {
+ const { rewards } = props;
+
+ if (!rewards || !rewards.length) {
+ return null;
+ }
+
+ return (
+ Claimed Rewards
+
+
+
+
+
+
+ {rewards.map(reward => {
+ return (
+ {__("Title")}
+ {__("Amount")}
+ {__("Transaction")}
+ {__("Date")}
+
+
+ );
+ })}
+
+ {reward.reward_title}
+ {reward.reward_amount}
+
+
+ {reward.created_at.replace("Z", " ").replace("T", " ")}
+
+ {reward.reward_title}
+
@@ -90,7 +44,7 @@ class RewardsPage extends React.PureComponent {
{__( @@ -122,25 +76,49 @@ class RewardsPage extends React.PureComponent {
- {__( - "This application is unable to earn rewards due to an authentication failure." - )} -
-+ {__( + "This application is unable to earn rewards due to an authentication failure." + )} +
+