From 2aedf5a188f028f61c45bc7ed0c747a2d4ae453a Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Tue, 12 Nov 2019 12:42:04 -0500 Subject: [PATCH] Fix: pagination support --- dist/bundle.es.js | 14 ++++++++++---- dist/bundle.js | 14 ++++++++++---- src/rewards.js | 36 ++++++++++++++++++++---------------- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index a9cee32..14c57ad 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -525,8 +525,11 @@ rewards.claimReward = (type, rewardParams) => { switch (type) { case rewards.TYPE_FIRST_CHANNEL: - lbryRedux.Lbry.claim_list().then(claims => { - const claim = claims.find(foundClaim => foundClaim.name.length && foundClaim.name[0] === '@' && foundClaim.txid.length && foundClaim.type === 'claim'); + lbryRedux.Lbry.channel_list({ + page: 1, + page_size: 10 + }).then(claims => { + const claim = claims.items && claims.items.find(foundClaim => foundClaim.name.length && foundClaim.name[0] === '@' && foundClaim.txid.length && foundClaim.type === 'claim'); if (claim) { params.transaction_id = claim.txid; @@ -538,8 +541,11 @@ rewards.claimReward = (type, rewardParams) => { break; case rewards.TYPE_FIRST_PUBLISH: - lbryRedux.Lbry.claim_list().then(claims => { - const claim = claims.find(foundClaim => foundClaim.name.length && foundClaim.name[0] !== '@' && foundClaim.txid.length && foundClaim.type === 'claim'); + lbryRedux.Lbry.stream_list({ + page: 1, + page_size: 10 + }).then(claims => { + const claim = claims.items && claims.items.find(foundClaim => foundClaim.name.length && foundClaim.name[0] !== '@' && foundClaim.txid.length && foundClaim.type === 'claim'); if (claim) { params.transaction_id = claim.txid; diff --git a/dist/bundle.js b/dist/bundle.js index 28c8db5..c56de74 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1289,8 +1289,11 @@ rewards.claimReward = function (type, rewardParams) { switch (type) { case rewards.TYPE_FIRST_CHANNEL: - lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].claim_list().then(function (claims) { - var claim = claims.find(function (foundClaim) { + lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].channel_list({ + page: 1, + page_size: 10 + }).then(function (claims) { + var claim = claims.items && claims.items.find(function (foundClaim) { return foundClaim.name.length && foundClaim.name[0] === '@' && foundClaim.txid.length && foundClaim.type === 'claim'; }); @@ -1304,8 +1307,11 @@ rewards.claimReward = function (type, rewardParams) { break; case rewards.TYPE_FIRST_PUBLISH: - lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].claim_list().then(function (claims) { - var claim = claims.find(function (foundClaim) { + lbry_redux__WEBPACK_IMPORTED_MODULE_0__["Lbry"].stream_list({ + page: 1, + page_size: 10 + }).then(function (claims) { + var claim = claims.items && claims.items.find(function (foundClaim) { return foundClaim.name.length && foundClaim.name[0] !== '@' && foundClaim.txid.length && foundClaim.type === 'claim'; }); diff --git a/src/rewards.js b/src/rewards.js index 46ca1e1..733554a 100644 --- a/src/rewards.js +++ b/src/rewards.js @@ -53,15 +53,17 @@ rewards.claimReward = (type, rewardParams) => { switch (type) { case rewards.TYPE_FIRST_CHANNEL: - Lbry.claim_list() + Lbry.channel_list({ page: 1, page_size: 10 }) .then(claims => { - const claim = claims.find( - foundClaim => - foundClaim.name.length && - foundClaim.name[0] === '@' && - foundClaim.txid.length && - foundClaim.type === 'claim' - ); + const claim = + claims.items && + claims.items.find( + foundClaim => + foundClaim.name.length && + foundClaim.name[0] === '@' && + foundClaim.txid.length && + foundClaim.type === 'claim' + ); if (claim) { params.transaction_id = claim.txid; requestReward(resolve, reject, params); @@ -73,15 +75,17 @@ rewards.claimReward = (type, rewardParams) => { break; case rewards.TYPE_FIRST_PUBLISH: - Lbry.claim_list() + Lbry.stream_list({ page: 1, page_size: 10 }) .then(claims => { - const claim = claims.find( - foundClaim => - foundClaim.name.length && - foundClaim.name[0] !== '@' && - foundClaim.txid.length && - foundClaim.type === 'claim' - ); + const claim = + claims.items && + claims.items.find( + foundClaim => + foundClaim.name.length && + foundClaim.name[0] !== '@' && + foundClaim.txid.length && + foundClaim.type === 'claim' + ); if (claim) { params.transaction_id = claim.txid; requestReward(resolve, reject, params);