Always use local availability checks (not Lighthouse)

This commit is contained in:
Alex Liebowitz 2017-01-20 23:55:49 -05:00
parent 78176e6b0a
commit 9b68f71199
2 changed files with 12 additions and 15 deletions

View file

@ -75,13 +75,11 @@ export let FileTileStream = React.createClass({
}
},
componentWillMount: function() {
if (!('available' in this.props)) {
lbry.getPeersForBlobHash(this.props.sdHash, (peers) => {
this.setState({
available: peers.length > 0,
});
lbry.getPeersForBlobHash(this.props.sdHash, (peers) => {
this.setState({
available: peers.length > 0,
});
}
});
},
componentDidMount: function() {
this._isMounted = true;
@ -94,9 +92,6 @@ export let FileTileStream = React.createClass({
lbry.fileInfoUnsubscribe(this.props.sdHash, this._fileInfoSubscribeId);
}
},
isAvailable: function() {
return 'available' in this.props ? this.props.available : this.state.available;
},
onFileInfoUpdate: function(fileInfo) {
if (!fileInfo && this._isMounted && this.props.hideOnRemove) {
this.setState({
@ -119,24 +114,26 @@ export let FileTileStream = React.createClass({
}
},
render: function() {
if (this.state.isHidden || (!lbry.getClientSetting('showUnavailable') && !this.isAvailable())) {
const isUnavailable = this.state.available === false;
if (this.state.isHidden || (!lbry.getClientSetting('showUnavailable') && isUnavailable)) {
return null;
}
const metadata = this.props.metadata || {},
obscureNsfw = this.props.obscureNsfw && metadata.nsfw,
title = metadata.title ? metadata.title : ('lbry://' + this.props.name),
showUnavailable = this.isAvailable() === false,
showAsAvailable = this.state.available !== false,
unavailableMessage = ("The content on LBRY is hosted by its users. It appears there are no " +
"users connected that have this file at the moment.");
return (
<section className={ 'file-tile card ' + (obscureNsfw ? 'card-obscured ' : '') } onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
{showUnavailable
{isUnavailable
? <div className='file-tile__not-available-message'>
This file is not currently available. <ToolTipLink label="Why?" tooltip={unavailableMessage} className="not-available-tooltip-link" />
</div>
: null}
<div className={"row-fluid card-content file-tile__row" + (showUnavailable ? ' file-tile__row--unavailable' : '')}>
<div className={"row-fluid card-content file-tile__row" + (isUnavailable ? ' file-tile__row--unavailable' : '')}>
<div className="span3">
<a href={'/?show=' + this.props.name}><Thumbnail className="file-tile__thumbnail" src={metadata.thumbnail} alt={'Photo for ' + (title || this.props.name)} /></a>
</div>

View file

@ -43,11 +43,11 @@ var SearchResults = React.createClass({
render: function() {
var rows = [],
seenNames = {}; //fix this when the search API returns claim IDs
this.props.results.forEach(function({name, peer_count}) {
this.props.results.forEach(function({name}) {
if (!seenNames[name]) {
seenNames[name] = name;
rows.push(
<FileTile key={name} name={name} available={peer_count > 0} />
<FileTile key={name} name={name} />
);
}
});