lbry-desktop/ui/js/actions/rewards.js
2017-06-05 21:21:55 -07:00

35 lines
726 B
JavaScript

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