Seed Support #56
5 changed files with 48 additions and 33 deletions
|
@ -121,7 +121,7 @@ export let FilePrice = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
if (this.state.cost === null && this.props.metadata) {
|
if (this.state.cost === null && this.props.metadata) {
|
||||||
if (!this.props.metadata.fee) {
|
if (!this.props.metadata.fee) {
|
||||||
return <span className="credit-amount">free</span>;
|
return <span className="credit-amount">free*</span>;
|
||||||
} else {
|
} else {
|
||||||
if (this.props.metadata.fee.currency === "LBC") {
|
if (this.props.metadata.fee.currency === "LBC") {
|
||||||
return <CreditAmount label={false} amount={this.props.metadata.fee.amount} isEstimate={true} />
|
return <CreditAmount label={false} amount={this.props.metadata.fee.amount} isEstimate={true} />
|
||||||
|
|
|
@ -208,19 +208,29 @@ lbry.getPeersForBlobHash = function(blobHash, 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.
|
||||||
*/
|
*/
|
||||||
|
lbry.costPromiseCache = {}
|
||||||
lbry.getCostInfo = function(lbryUri) {
|
lbry.getCostInfo = function(lbryUri) {
|
||||||
return new Promise((resolve, reject) => {
|
if (lbry.costPromiseCache[lbryUri] === undefined) {
|
||||||
|
const COST_INFO_CACHE_KEY = 'cost_info_cache';
|
||||||
|
lbry.costPromiseCache[lbryUri] = new Promise((resolve, reject) => {
|
||||||
|
let costInfoCache = getSession(COST_INFO_CACHE_KEY, {})
|
||||||
|
|
||||||
if (!lbryUri) {
|
if (!lbryUri) {
|
||||||
reject(new Error(`URI required.`));
|
reject(new Error(`URI required.`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (costInfoCache[lbryUri] && costInfoCache[lbryUri].cost) {
|
||||||
|
return resolve(costInfoCache[lbryUri])
|
||||||
|
}
|
||||||
|
|
||||||
function getCost(lbryUri, size) {
|
function getCost(lbryUri, size) {
|
||||||
lbry.stream_cost_estimate({uri: lbryUri, ... size !== null ? {size} : {}}).then((cost) => {
|
lbry.stream_cost_estimate({uri: lbryUri, ... size !== null ? {size} : {}}).then((cost) => {
|
||||||
resolve({
|
costInfoCache[lbryUri] = {
|
||||||
cost: cost,
|
cost: cost,
|
||||||
includesData: size !== null,
|
includesData: size !== null,
|
||||||
});
|
};
|
||||||
|
setSession(COST_INFO_CACHE_KEY, costInfoCache);
|
||||||
|
resolve(costInfoCache[lbryUri]);
|
||||||
}, reject);
|
}, reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,13 +240,16 @@ lbry.getCostInfo = function(lbryUri) {
|
||||||
lighthouse.get_size_for_name(name).then((size) => {
|
lighthouse.get_size_for_name(name).then((size) => {
|
||||||
if (size) {
|
if (size) {
|
||||||
getCost(name, size);
|
getCost(name, size);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
getCost(name, null);
|
getCost(name, null);
|
||||||
}
|
}
|
||||||
}, () => {
|
}, () => {
|
||||||
getCost(name, null);
|
getCost(name, null);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
return lbry.costPromiseCache[lbryUri];
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getMyClaims = function(callback) {
|
lbry.getMyClaims = function(callback) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import lbry from './lbry.js';
|
import lbry from './lbry.js';
|
||||||
import jsonrpc from './jsonrpc.js';
|
import jsonrpc from './jsonrpc.js';
|
||||||
|
|
||||||
const queryTimeout = 5000;
|
const queryTimeout = 3000;
|
||||||
const maxQueryTries = 5;
|
const maxQueryTries = 2;
|
||||||
const defaultServers = [
|
const defaultServers = [
|
||||||
'http://lighthouse4.lbry.io:50005',
|
'http://lighthouse4.lbry.io:50005',
|
||||||
'http://lighthouse5.lbry.io:50005',
|
'http://lighthouse5.lbry.io:50005',
|
||||||
|
@ -20,8 +20,9 @@ function getServers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function call(method, params, callback, errorCallback) {
|
function call(method, params, callback, errorCallback) {
|
||||||
if (connectTryNum > maxQueryTries) {
|
if (connectTryNum >= maxQueryTries) {
|
||||||
errorCallback(new Error(`Could not connect to Lighthouse server. Last server attempted: ${server}`));
|
errorCallback(new Error(`Could not connect to Lighthouse server. Last server attempted: ${server}`));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -162,12 +162,12 @@ export let FileList = React.createClass({
|
||||||
|
|
||||||
const fileInfosSorted = this._sortFunctions[this.state.sortBy](this.props.fileInfos);
|
const fileInfosSorted = this._sortFunctions[this.state.sortBy](this.props.fileInfos);
|
||||||
for (let {outpoint, name, channel_name, metadata: {stream: {metadata}}, mime_type, claim_id, has_signature, signature_is_valid} of fileInfosSorted) {
|
for (let {outpoint, name, channel_name, metadata: {stream: {metadata}}, mime_type, claim_id, has_signature, signature_is_valid} of fileInfosSorted) {
|
||||||
if (!metadata || seenUris[name] || channel_name === null) {
|
if (!metadata || seenUris[name]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileUri;
|
let fileUri;
|
||||||
if (channel_name === undefined) {
|
if (!channel_name) {
|
||||||
fileUri = uri.buildLbryUri({name});
|
fileUri = uri.buildLbryUri({name});
|
||||||
} else {
|
} else {
|
||||||
fileUri = uri.buildLbryUri({name: channel_name, path: name});
|
fileUri = uri.buildLbryUri({name: channel_name, path: name});
|
||||||
|
|
|
@ -91,6 +91,7 @@ let ShowPage = React.createClass({
|
||||||
metadata = this.state.uriLookupComplete ? this.state.metadata : null,
|
metadata = this.state.uriLookupComplete ? this.state.metadata : null,
|
||||||
title = this.state.uriLookupComplete ? metadata.title : this._uri;
|
title = this.state.uriLookupComplete ? metadata.title : this._uri;
|
||||||
|
|
||||||
|
console.log(metadata);
|
||||||
return (
|
return (
|
||||||
<main className="constrained-page">
|
<main className="constrained-page">
|
||||||
<section className="show-page-media">
|
<section className="show-page-media">
|
||||||
|
@ -101,7 +102,7 @@ let ShowPage = React.createClass({
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<div className="card__inner">
|
<div className="card__inner">
|
||||||
<div className="card__title-identity">
|
<div className="card__title-identity">
|
||||||
<span style={{float: "right"}}><FilePrice uri={this._uri} /></span>
|
<span style={{float: "right"}}><FilePrice uri={this._uri} metadata={metadata} /></span>
|
||||||
<h1>{title}</h1>
|
<h1>{title}</h1>
|
||||||
{ this.state.uriLookupComplete ?
|
{ this.state.uriLookupComplete ?
|
||||||
<div>
|
<div>
|
||||||
|
@ -109,7 +110,7 @@ let ShowPage = React.createClass({
|
||||||
<UriIndicator uri={this._uri} hasSignature={this.state.hasSignature} signatureIsValid={this.state.signatureIsValid} />
|
<UriIndicator uri={this._uri} hasSignature={this.state.hasSignature} signatureIsValid={this.state.signatureIsValid} />
|
||||||
</div>
|
</div>
|
||||||
<div className="card__actions">
|
<div className="card__actions">
|
||||||
<FileActions uri={this._uri} outpoint={this.state.outpoint} metadata={this.state.metadata} contentType={this.state.contentType} />
|
<FileActions uri={this._uri} outpoint={this.state.outpoint} metadata={metadata} contentType={this.state.contentType} />
|
||||||
</div>
|
</div>
|
||||||
</div> : '' }
|
</div> : '' }
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue