2017-06-06 23:19:12 +02:00
|
|
|
|
import React from "react";
|
|
|
|
|
import lbryuri from "lbryuri";
|
|
|
|
|
import { BusyMessage } from "component/common";
|
|
|
|
|
import FileTile from "component/fileTile";
|
2017-07-17 08:06:04 +02:00
|
|
|
|
import Link from "component/link";
|
|
|
|
|
import ReactPaginate from "react-paginate";
|
2017-05-04 05:44:08 +02:00
|
|
|
|
|
2017-06-08 06:42:19 +02:00
|
|
|
|
class ChannelPage extends React.PureComponent {
|
2017-05-13 00:50:51 +02:00
|
|
|
|
componentDidMount() {
|
2017-07-17 08:06:04 +02:00
|
|
|
|
const { uri, params, fetchClaims } = this.props;
|
|
|
|
|
|
|
|
|
|
fetchClaims(uri, params.page || 1);
|
2017-05-13 00:50:51 +02:00
|
|
|
|
}
|
2017-05-04 05:44:08 +02:00
|
|
|
|
|
2017-05-13 00:50:51 +02:00
|
|
|
|
componentWillReceiveProps(nextProps) {
|
2017-07-17 08:06:04 +02:00
|
|
|
|
const { params, fetching, fetchClaims } = this.props;
|
|
|
|
|
const nextParams = nextProps.params;
|
|
|
|
|
|
|
|
|
|
if (fetching !== nextParams.page && params.page !== nextParams.page)
|
|
|
|
|
fetchClaims(nextProps.uri, nextParams.page);
|
2017-05-13 00:50:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-17 08:06:04 +02:00
|
|
|
|
changePage(pageNumber) {
|
|
|
|
|
const { params, currentPage } = this.props;
|
|
|
|
|
const newParams = Object.assign({}, params, { page: pageNumber });
|
|
|
|
|
|
|
|
|
|
this.props.navigate("/show", newParams);
|
2017-05-13 00:50:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2017-07-17 08:06:04 +02:00
|
|
|
|
const {
|
|
|
|
|
fetching,
|
|
|
|
|
claimsInChannel,
|
|
|
|
|
claim,
|
|
|
|
|
uri,
|
|
|
|
|
params,
|
|
|
|
|
totalPages,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { page } = params;
|
2017-05-13 00:50:51 +02:00
|
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
|
let contentList;
|
2017-05-21 16:42:34 +02:00
|
|
|
|
if (claimsInChannel === undefined) {
|
2017-06-06 23:19:12 +02:00
|
|
|
|
contentList = <BusyMessage message={__("Fetching content")} />;
|
2017-05-21 16:42:34 +02:00
|
|
|
|
} else if (claimsInChannel) {
|
2017-06-06 23:19:12 +02:00
|
|
|
|
contentList = claimsInChannel.length
|
|
|
|
|
? claimsInChannel.map(claim =>
|
|
|
|
|
<FileTile
|
|
|
|
|
key={claim.claim_id}
|
2017-07-17 08:06:04 +02:00
|
|
|
|
uri={lbryuri.build({
|
|
|
|
|
name: claim.name,
|
|
|
|
|
claimId: claim.claim_id,
|
|
|
|
|
})}
|
2017-06-06 23:19:12 +02:00
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
: <span className="empty">{__("No content found.")}</span>;
|
2017-05-21 16:42:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
|
return (
|
2017-07-17 08:06:04 +02:00
|
|
|
|
<div>
|
2017-06-06 23:19:12 +02:00
|
|
|
|
<section className="card">
|
|
|
|
|
<div className="card__inner">
|
|
|
|
|
<div className="card__title-identity"><h1>{uri}</h1></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="card__content">
|
2017-06-28 22:17:22 +02:00
|
|
|
|
<p className="empty">
|
|
|
|
|
{__(
|
|
|
|
|
"Channel pages are empty for all publishers currently, but will be coming in a future update."
|
|
|
|
|
)}
|
2017-06-06 23:19:12 +02:00
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
<h3 className="card-row__header">{__("Published Content")}</h3>
|
|
|
|
|
{contentList}
|
2017-07-17 08:06:04 +02:00
|
|
|
|
<div />
|
|
|
|
|
{(!fetching || (claimsInChannel && claimsInChannel.length)) &&
|
|
|
|
|
totalPages > 1 &&
|
|
|
|
|
<ReactPaginate
|
|
|
|
|
pageCount={totalPages}
|
|
|
|
|
pageRangeDisplayed={2}
|
2017-07-29 21:34:22 +02:00
|
|
|
|
previousLabel="‹"
|
|
|
|
|
nextLabel="›"
|
|
|
|
|
activeClassName="pagination__item--selected"
|
|
|
|
|
pageClassName="pagination__item"
|
|
|
|
|
previousClassName="pagination__item pagination__item--previous"
|
|
|
|
|
nextClassName="pagination__item pagination__item--next"
|
2017-08-09 06:16:25 +02:00
|
|
|
|
breakClassName="pagination__item pagination__item--break"
|
2017-07-17 08:06:04 +02:00
|
|
|
|
marginPagesDisplayed={2}
|
|
|
|
|
onPageChange={e => this.changePage(e.selected + 1)}
|
|
|
|
|
initialPage={parseInt(page - 1)}
|
|
|
|
|
containerClassName="pagination"
|
|
|
|
|
/>}
|
|
|
|
|
</div>
|
2017-06-06 23:19:12 +02:00
|
|
|
|
);
|
2017-05-13 00:50:51 +02:00
|
|
|
|
}
|
2017-05-04 05:44:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ChannelPage;
|