On Show page, don't display wrong name when given a nonexistent name
Now shows 404-like "no content here" message instead
This commit is contained in:
parent
2bc90f9957
commit
c8220e0c08
1 changed files with 24 additions and 7 deletions
|
@ -107,6 +107,7 @@ var DetailPage = React.createClass({
|
||||||
claimInfo: null,
|
claimInfo: null,
|
||||||
amount: null,
|
amount: null,
|
||||||
searching: true,
|
searching: true,
|
||||||
|
matchFound: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
@ -114,12 +115,21 @@ var DetailPage = React.createClass({
|
||||||
|
|
||||||
lbry.search(this.props.name, (results) => {
|
lbry.search(this.props.name, (results) => {
|
||||||
var result = results[0];
|
var result = results[0];
|
||||||
this.setState({
|
|
||||||
amount: result.cost,
|
if (result.name != this.props.name) {
|
||||||
available: result.available,
|
this.setState({
|
||||||
claimInfo: result.value,
|
searching: false,
|
||||||
searching: false,
|
matchFound: false,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
amount: result.cost,
|
||||||
|
available: result.available,
|
||||||
|
claimInfo: result.value,
|
||||||
|
searching: false,
|
||||||
|
matchFound: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
@ -136,7 +146,14 @@ var DetailPage = React.createClass({
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<FormatsSection name={name} claimInfo={claimInfo} amount={amount} available={available} />
|
{this.state.matchFound ? (
|
||||||
|
<FormatsSection name={name} claimInfo={claimInfo} amount={amount} available={available} />
|
||||||
|
) : (
|
||||||
|
<div>
|
||||||
|
<h2>No content</h2>
|
||||||
|
There is no content available at the name <strong>lbry://{this.props.name}</strong>. If you reached this page from a link within the LBRY interface, please <Link href="/?report" label="report a bug" />. Thanks!
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</section>
|
</section>
|
||||||
</main>);
|
</main>);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue