2017-05-05 08:13:06 +02:00
|
|
|
import React from 'react';
|
2017-05-19 01:14:26 +02:00
|
|
|
import lbryuri from 'lbryuri'
|
2017-05-05 08:13:06 +02:00
|
|
|
import {
|
|
|
|
BusyMessage,
|
|
|
|
} from 'component/common';
|
2017-05-19 01:14:26 +02:00
|
|
|
import ChannelPage from 'page/channel'
|
2017-05-05 08:13:06 +02:00
|
|
|
import FilePage from 'page/filePage'
|
|
|
|
|
2017-05-10 05:06:48 +02:00
|
|
|
class ShowPage extends React.Component{
|
|
|
|
componentWillMount() {
|
2017-05-12 01:28:43 +02:00
|
|
|
this.resolve(this.props)
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
this.resolve(nextProps)
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(props) {
|
2017-05-10 05:06:48 +02:00
|
|
|
const {
|
|
|
|
isResolvingUri,
|
|
|
|
resolveUri,
|
|
|
|
claim,
|
|
|
|
uri,
|
2017-05-12 01:28:43 +02:00
|
|
|
} = props
|
2017-05-10 05:06:48 +02:00
|
|
|
|
2017-05-12 22:49:15 +02:00
|
|
|
if(!isResolvingUri && claim === undefined && uri) {
|
2017-05-10 05:06:48 +02:00
|
|
|
resolveUri(uri)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
2017-05-12 01:28:43 +02:00
|
|
|
claim,
|
2017-05-10 05:06:48 +02:00
|
|
|
uri,
|
|
|
|
isResolvingUri,
|
|
|
|
} = this.props
|
2017-05-05 08:13:06 +02:00
|
|
|
|
|
|
|
let innerContent = "";
|
|
|
|
|
2017-05-15 05:50:59 +02:00
|
|
|
if (isResolvingUri || !claim) {
|
2017-05-05 08:13:06 +02:00
|
|
|
innerContent = <section className="card">
|
2017-05-10 05:06:48 +02:00
|
|
|
<div className="card__inner">
|
2017-05-12 01:28:43 +02:00
|
|
|
<div className="card__title-identity"><h1>{uri}</h1></div>
|
2017-05-10 05:06:48 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
2017-05-12 22:49:15 +02:00
|
|
|
{ isResolvingUri && <BusyMessage message="Loading magic decentralized data..." /> }
|
|
|
|
{ claim === null && <span className="empty">There's nothing at this location.</span> }
|
2017-05-10 05:06:48 +02:00
|
|
|
</div>
|
2017-05-12 22:49:15 +02:00
|
|
|
</section>
|
2017-05-10 05:06:48 +02:00
|
|
|
}
|
2017-05-15 05:50:59 +02:00
|
|
|
else if (claim.name.length && claim.name[0] === '@') {
|
2017-05-21 16:42:34 +02:00
|
|
|
innerContent = <ChannelPage uri={uri} />
|
2017-05-10 05:06:48 +02:00
|
|
|
}
|
2017-05-12 01:28:43 +02:00
|
|
|
else if (claim) {
|
2017-05-15 05:50:59 +02:00
|
|
|
innerContent = <FilePage uri={uri} />
|
2017-05-05 08:13:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<main className="main--single-column">{innerContent}</main>
|
|
|
|
)
|
2017-05-10 05:06:48 +02:00
|
|
|
}
|
2017-05-05 08:13:06 +02:00
|
|
|
}
|
|
|
|
|
2017-05-15 05:50:59 +02:00
|
|
|
export default ShowPage
|