featured download reward

This commit is contained in:
Jeremy Kauffman 2017-05-26 11:56:32 -04:00
parent 0350dd1610
commit ca4442f767
2 changed files with 8 additions and 3 deletions

View file

@ -122,7 +122,7 @@ export function doUpdateLoadStatus(uri, outpoint) {
} else if (fileInfo.completed) {
// TODO this isn't going to get called if they reload the client before
// the download finished
rewards.claimNextPurchaseReward()
rewards.claimEligiblePurchaseRewards()
dispatch({
type: types.DOWNLOADING_COMPLETED,
data: {

View file

@ -76,6 +76,7 @@ rewards.TYPE_FIRST_CHANNEL = "new_channel",
rewards.TYPE_FIRST_STREAM = "first_stream",
rewards.TYPE_MANY_DOWNLOADS = "many_downloads",
rewards.TYPE_FIRST_PUBLISH = "first_publish";
rewards.TYPE_FEATURED_DOWNLOAD = "featured_download";
rewards.claimReward = function (type) {
@ -155,9 +156,10 @@ rewards.claimReward = function (type) {
});
}
rewards.claimNextPurchaseReward = function() {
rewards.claimEligiblePurchaseRewards = function() {
let types = {}
types[rewards.TYPE_FIRST_STREAM] = false
types[rewards.TYPE_FEATURED_DOWNLOAD] = false
types[rewards.TYPE_MANY_DOWNLOADS] = false
lbryio.call('reward', 'list', {}).then((userRewards) => {
userRewards.forEach((reward) => {
@ -166,11 +168,14 @@ rewards.claimNextPurchaseReward = function() {
}
})
let unclaimedType = Object.keys(types).find((type) => {
return types[type] === false;
return types[type] === false && type !== rewards.TYPE_FEATURED_DOWNLOAD; //handled below
})
if (unclaimedType) {
rewards.claimReward(unclaimedType);
}
if (types[rewards.TYPE_FEATURED_DOWNLOAD] === false) {
rewards.claimReward(rewards.TYPE_FEATURED_DOWNLOAD)
}
}, () => { });
}