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

36 lines
726 B
JavaScript
Raw Normal View History

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