Always use local availability checks (not Lighthouse)
This commit is contained in:
parent
78176e6b0a
commit
9b68f71199
2 changed files with 12 additions and 15 deletions
|
@ -75,13 +75,11 @@ export let FileTileStream = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
if (!('available' in this.props)) {
|
lbry.getPeersForBlobHash(this.props.sdHash, (peers) => {
|
||||||
lbry.getPeersForBlobHash(this.props.sdHash, (peers) => {
|
this.setState({
|
||||||
this.setState({
|
available: peers.length > 0,
|
||||||
available: peers.length > 0,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
},
|
},
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this._isMounted = true;
|
this._isMounted = true;
|
||||||
|
@ -94,9 +92,6 @@ export let FileTileStream = React.createClass({
|
||||||
lbry.fileInfoUnsubscribe(this.props.sdHash, this._fileInfoSubscribeId);
|
lbry.fileInfoUnsubscribe(this.props.sdHash, this._fileInfoSubscribeId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isAvailable: function() {
|
|
||||||
return 'available' in this.props ? this.props.available : this.state.available;
|
|
||||||
},
|
|
||||||
onFileInfoUpdate: function(fileInfo) {
|
onFileInfoUpdate: function(fileInfo) {
|
||||||
if (!fileInfo && this._isMounted && this.props.hideOnRemove) {
|
if (!fileInfo && this._isMounted && this.props.hideOnRemove) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -119,24 +114,26 @@ export let FileTileStream = React.createClass({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: function() {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const metadata = this.props.metadata || {},
|
const metadata = this.props.metadata || {},
|
||||||
obscureNsfw = this.props.obscureNsfw && metadata.nsfw,
|
obscureNsfw = this.props.obscureNsfw && metadata.nsfw,
|
||||||
title = metadata.title ? metadata.title : ('lbry://' + this.props.name),
|
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 " +
|
unavailableMessage = ("The content on LBRY is hosted by its users. It appears there are no " +
|
||||||
"users connected that have this file at the moment.");
|
"users connected that have this file at the moment.");
|
||||||
return (
|
return (
|
||||||
<section className={ 'file-tile card ' + (obscureNsfw ? 'card-obscured ' : '') } onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
|
<section className={ 'file-tile card ' + (obscureNsfw ? 'card-obscured ' : '') } onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
|
||||||
{showUnavailable
|
{isUnavailable
|
||||||
? <div className='file-tile__not-available-message'>
|
? <div className='file-tile__not-available-message'>
|
||||||
This file is not currently available. <ToolTipLink label="Why?" tooltip={unavailableMessage} className="not-available-tooltip-link" />
|
This file is not currently available. <ToolTipLink label="Why?" tooltip={unavailableMessage} className="not-available-tooltip-link" />
|
||||||
</div>
|
</div>
|
||||||
: null}
|
: 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">
|
<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>
|
<a href={'/?show=' + this.props.name}><Thumbnail className="file-tile__thumbnail" src={metadata.thumbnail} alt={'Photo for ' + (title || this.props.name)} /></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -43,11 +43,11 @@ var SearchResults = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
var rows = [],
|
var rows = [],
|
||||||
seenNames = {}; //fix this when the search API returns claim IDs
|
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]) {
|
if (!seenNames[name]) {
|
||||||
seenNames[name] = name;
|
seenNames[name] = name;
|
||||||
rows.push(
|
rows.push(
|
||||||
<FileTile key={name} name={name} available={peer_count > 0} />
|
<FileTile key={name} name={name} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue