Seed Support #56

Closed
ocnios wants to merge 173 commits from master into build
5 changed files with 48 additions and 33 deletions
Showing only changes of commit 736d769fa6 - Show all commits

View file

@ -121,7 +121,7 @@ export let FilePrice = React.createClass({
render: function() {
if (this.state.cost === null && this.props.metadata) {
if (!this.props.metadata.fee) {
return <span className="credit-amount">free</span>;
return <span className="credit-amount">free*</span>;
} else {
if (this.props.metadata.fee.currency === "LBC") {
return <CreditAmount label={false} amount={this.props.metadata.fee.amount} isEstimate={true} />

View file

@ -208,35 +208,48 @@ lbry.getPeersForBlobHash = function(blobHash, callback) {
* - includes_data: Boolean; indicates whether or not the data fee info
* from Lighthouse is included.
*/
lbry.costPromiseCache = {}
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) {
reject(new Error(`URI required.`));
}
function getCost(lbryUri, size) {
lbry.stream_cost_estimate({uri: lbryUri, ... size !== null ? {size} : {}}).then((cost) => {
resolve({
cost: cost,
includesData: size !== null,
});
}, reject);
}
const uriObj = uri.parseLbryUri(lbryUri);
const name = uriObj.path || uriObj.name;
lighthouse.get_size_for_name(name).then((size) => {
if (size) {
getCost(name, size);
} else {
getCost(name, null);
if (!lbryUri) {
reject(new Error(`URI required.`));
}
}, () => {
getCost(name, null);
if (costInfoCache[lbryUri] && costInfoCache[lbryUri].cost) {
return resolve(costInfoCache[lbryUri])
}
function getCost(lbryUri, size) {
lbry.stream_cost_estimate({uri: lbryUri, ... size !== null ? {size} : {}}).then((cost) => {
costInfoCache[lbryUri] = {
cost: cost,
includesData: size !== null,
};
setSession(COST_INFO_CACHE_KEY, costInfoCache);
resolve(costInfoCache[lbryUri]);
}, reject);
}
const uriObj = uri.parseLbryUri(lbryUri);
const name = uriObj.path || uriObj.name;
lighthouse.get_size_for_name(name).then((size) => {
if (size) {
getCost(name, size);
}
else {
getCost(name, null);
}
}, () => {
getCost(name, null);
});
});
})
}
return lbry.costPromiseCache[lbryUri];
}
lbry.getMyClaims = function(callback) {

View file

@ -1,8 +1,8 @@
import lbry from './lbry.js';
import jsonrpc from './jsonrpc.js';
const queryTimeout = 5000;
const maxQueryTries = 5;
const queryTimeout = 3000;
const maxQueryTries = 2;
const defaultServers = [
'http://lighthouse4.lbry.io:50005',
'http://lighthouse5.lbry.io:50005',
@ -20,8 +20,9 @@ function getServers() {
}
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}`));
return;
}
/**

View file

@ -162,12 +162,12 @@ export let FileList = React.createClass({
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) {
if (!metadata || seenUris[name] || channel_name === null) {
if (!metadata || seenUris[name]) {
continue;
}
let fileUri;
if (channel_name === undefined) {
if (!channel_name) {
fileUri = uri.buildLbryUri({name});
} else {
fileUri = uri.buildLbryUri({name: channel_name, path: name});

View file

@ -91,6 +91,7 @@ let ShowPage = React.createClass({
metadata = this.state.uriLookupComplete ? this.state.metadata : null,
title = this.state.uriLookupComplete ? metadata.title : this._uri;
console.log(metadata);
return (
<main className="constrained-page">
<section className="show-page-media">
@ -101,7 +102,7 @@ let ShowPage = React.createClass({
<section className="card">
<div className="card__inner">
<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>
{ this.state.uriLookupComplete ?
<div>
@ -109,7 +110,7 @@ let ShowPage = React.createClass({
<UriIndicator uri={this._uri} hasSignature={this.state.hasSignature} signatureIsValid={this.state.signatureIsValid} />
</div>
<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>