lbry-desktop/ui/js/page/showPage/view.jsx

58 lines
1.5 KiB
React
Raw Normal View History

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