more bug fixes + optimizations

This commit is contained in:
Jeremy Kauffman 2017-05-12 14:36:44 -04:00
parent 5605b10f54
commit 950f3183cf
5 changed files with 22 additions and 24 deletions

View file

@ -92,7 +92,7 @@ class FileTile extends React.Component {
let description = ""
if (isClaimed) {
description = metadata.description
description = metadata && metadata.description
} else if (isResolvingUri) {
description = "Loading..."
} else if (showEmpty === FileTile.SHOW_EMPTY_PUBLISH) {

View file

@ -32,9 +32,6 @@ class WatchLink extends React.Component {
fileInfo,
} = this.props
console.log('watch link render')
console.log(fileInfo)
return (<div>
<Link button={ button ? button : null }
disabled={isLoading || !costInfo || costInfo.cost == undefined || fileInfo === undefined}

View file

@ -99,10 +99,18 @@ class WunderBar extends React.PureComponent {
}
componentDidUpdate() {
this._input.value = this.state.address;
if (this._input && this._focusPending) {
this._input.select();
this._focusPending = false;
if (this._input) {
const start = this._input.selectionStart,
end = this._input.selectionEnd;
this._input.value = this.state.address; //this causes cursor to go to end of input
this._input.setSelectionRange(start, end);
if (this._focusPending) {
this._input.select();
this._focusPending = false;
}
}
}

View file

@ -13,25 +13,19 @@ const lbryio = {
const CONNECTION_STRING = 'https://api.lbry.io/';
const EXCHANGE_RATE_TIMEOUT = 20 * 60 * 1000;
lbryio._exchangePromise = null;
lbryio._exchangeLastFetched = null;
lbryio.getExchangeRates = function() {
const cached = getSession('exchangeRateCache');
if (!cached || Date.now() - cached.time > EXCHANGE_RATE_TIMEOUT) {
}
return new Promise((resolve, reject) => {
if (!cached || Date.now() - cached.time > EXCHANGE_RATE_TIMEOUT) {
if (!lbryio._exchangeLastFetched || Date.now() - lbryio._exchangeLastFetched > EXCHANGE_RATE_TIMEOUT) {
lbryio._exchangePromise = new Promise((resolve, reject) => {
lbryio.call('lbc', 'exchange_rate', {}, 'get', true).then(({lbc_usd, lbc_btc, btc_usd}) => {
const rates = {lbc_usd, lbc_btc, btc_usd};
setSession('exchangeRateCache', {
rates: rates,
time: Date.now(),
});
resolve(rates);
});
} else {
resolve(cached.rates);
}
});
}).catch(reject);
});
lbryio._exchangeLastFetched = Date.now();
}
return lbryio._exchangePromise;
}
lbryio.call = function(resource, action, params={}, method='get', evenIfDisabled=false) { // evenIfDisabled is just for development, when we may have some calls working and some not

View file

@ -57,7 +57,6 @@ class FilePage extends React.Component{
fetchFileInfo(props) {
if (!props.fileInfo) {
console.log('fetch file info')
props.fetchFileInfo()
}
}