Don't show error message if price for a file can't be retrieved

On search results pages, stream_cost_estimate is called on every
result. If there's some problem in the daemon that affects all calls
to stream_cost_estimate, this can lead to 25 error boxes. Better to
just suppress the error and not display a price.

Also switched to the new name for the daemon method (get_cost_est ->
stream_cost_estimate)
This commit is contained in:
Alex Liebowitz 2017-01-24 19:17:00 -05:00
parent 2900f6e14d
commit 423d4fa47b
2 changed files with 15 additions and 13 deletions

View file

@ -28,6 +28,8 @@ let FilePrice = React.createClass({
costIncludesData: includesData, costIncludesData: includesData,
}); });
} }
}, () => {
// If we get an error looking up cost information, do nothing
}); });
}, },

View file

@ -179,15 +179,15 @@ lbry.getMyClaim = function(name, callback) {
lbry.call('get_my_claim', { name: name }, callback); lbry.call('get_my_claim', { name: name }, callback);
} }
lbry.getKeyFee = function(name, callback) { lbry.getKeyFee = function(name, callback, errorCallback) {
lbry.call('get_est_cost', { name: name }, callback); lbry.call('stream_cost_estimate', { name: name }, callback, errorCallback);
} }
lbry.getTotalCost = function(name, size, callback) { lbry.getTotalCost = function(name, size, callback, errorCallback) {
lbry.call('get_est_cost', { lbry.call('stream_cost_estimate', {
name: name, name: name,
size: size, size: size,
}, callback); }, callback, errorCallback);
} }
lbry.getPeersForBlobHash = function(blobHash, callback) { lbry.getPeersForBlobHash = function(blobHash, callback) {
@ -205,7 +205,7 @@ lbry.getPeersForBlobHash = function(blobHash, callback) {
}); });
} }
lbry.getCostInfoForName = function(name, callback) { lbry.getCostInfoForName = function(name, callback, errorCallback) {
/** /**
* Takes a LBRY name; will first try and calculate a total cost using * Takes a LBRY name; will first try and calculate a total cost using
* Lighthouse. If Lighthouse can't be reached, it just retrives the * Lighthouse. If Lighthouse can't be reached, it just retrives the
@ -216,30 +216,30 @@ lbry.getCostInfoForName = function(name, callback) {
* - includes_data: Boolean; indicates whether or not the data fee info * - includes_data: Boolean; indicates whether or not the data fee info
* from Lighthouse is included. * from Lighthouse is included.
*/ */
function getCostWithData(name, size, callback) { function getCostWithData(name, size, callback, errorCallback) {
lbry.getTotalCost(name, size, (cost) => { lbry.getTotalCost(name, size, (cost) => {
callback({ callback({
cost: cost, cost: cost,
includesData: true, includesData: true,
}); });
}); }, errorCallback);
} }
function getCostNoData(name, callback) { function getCostNoData(name, callback, errorCallback) {
lbry.getKeyFee(name, (cost) => { lbry.getKeyFee(name, (cost) => {
callback({ callback({
cost: cost, cost: cost,
includesData: false, includesData: false,
}); });
}); }, errorCallback);
} }
lighthouse.getSizeForName(name, (size) => { lighthouse.getSizeForName(name, (size) => {
getCostWithData(name, size, callback); getCostWithData(name, size, callback, errorCallback);
}, () => { }, () => {
getCostNoData(name, callback); getCostNoData(name, callback, errorCallback);
}, () => { }, () => {
getCostNoData(name, callback); getCostNoData(name, callback, errorCallback);
}); });
} }