2017-06-06 23:19:12 +02:00
|
|
|
import * as types from "constants/action_types";
|
|
|
|
import lbry from "lbry";
|
|
|
|
import lbryio from "lbryio";
|
|
|
|
import rewards from "rewards";
|
2017-04-24 09:25:27 +02:00
|
|
|
|
|
|
|
export function doFetchRewards() {
|
|
|
|
return function(dispatch, getState) {
|
2017-06-06 23:19:12 +02:00
|
|
|
const state = getState();
|
2017-04-24 09:25:27 +02:00
|
|
|
|
|
|
|
dispatch({
|
|
|
|
type: types.FETCH_REWARDS_STARTED,
|
2017-06-06 23:19:12 +02:00
|
|
|
});
|
2017-04-24 09:25:27 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
lbryio.call("reward", "list", {}).then(function(userRewards) {
|
2017-04-24 09:25:27 +02:00
|
|
|
dispatch({
|
|
|
|
type: types.FETCH_REWARDS_COMPLETED,
|
2017-06-06 23:19:12 +02:00
|
|
|
data: { userRewards },
|
|
|
|
});
|
2017-04-24 09:25:27 +02:00
|
|
|
});
|
2017-06-06 23:19:12 +02:00
|
|
|
};
|
2017-04-24 09:25:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function doClaimReward(rewardType) {
|
|
|
|
return function(dispatch, getState) {
|
|
|
|
try {
|
2017-06-06 23:19:12 +02:00
|
|
|
rewards.claimReward(rewards[rewardType]);
|
2017-04-24 09:25:27 +02:00
|
|
|
dispatch({
|
|
|
|
type: types.REWARD_CLAIMED,
|
|
|
|
data: {
|
2017-06-06 23:19:12 +02:00
|
|
|
reward: rewards[rewardType],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
} catch (err) {}
|
|
|
|
};
|
2017-04-24 09:25:27 +02:00
|
|
|
}
|