lbry-desktop/ui/js/actions/rewards.js

36 lines
791 B
JavaScript
Raw Normal View History

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";
export function doFetchRewards() {
return function(dispatch, getState) {
2017-06-06 23:19:12 +02:00
const state = getState();
dispatch({
type: types.FETCH_REWARDS_STARTED,
2017-06-06 23:19:12 +02:00
});
2017-06-06 23:19:12 +02:00
lbryio.call("reward", "list", {}).then(function(userRewards) {
dispatch({
type: types.FETCH_REWARDS_COMPLETED,
2017-06-06 23:19:12 +02:00
data: { userRewards },
});
});
2017-06-06 23:19:12 +02:00
};
}
export function doClaimReward(rewardType) {
return function(dispatch, getState) {
try {
2017-06-06 23:19:12 +02:00
rewards.claimReward(rewards[rewardType]);
dispatch({
type: types.REWARD_CLAIMED,
data: {
2017-06-06 23:19:12 +02:00
reward: rewards[rewardType],
},
});
} catch (err) {}
};
}