import React from "react";
import lbry from "lbry.js";
import lbryio from "lbryio.js";
import lbryuri from "lbryuri";
import FileCard from "component/fileCard";
import { BusyMessage } from "component/common.js";
import ToolTip from "component/tooltip.js";
const FeaturedCategory = props => {
const { category, names } = props;
return (
{category}
{category &&
category.match(/^community/i) &&
}
{names &&
names.map(name =>
)}
);
};
class DiscoverPage extends React.PureComponent {
componentWillMount() {
this.props.fetchFeaturedUris();
this.scrollListener = this.handleScroll.bind(this);
}
componentDidMount() {
if (this.props.isNavigatingBack) {
const scrollY = parseInt(lbry.getClientSetting("prefs_scrolly"));
if (!isNaN(scrollY)) {
const restoreScrollPosition = () => {
window.scrollTo(0, scrollY);
};
setTimeout(restoreScrollPosition, 100);
}
this.props.finishedNavigatingBack();
}
window.addEventListener("scroll", this.scrollListener);
}
handleScroll() {
lbry.setClientSetting("prefs_scrolly", window.scrollY);
}
componentWillUnmount() {
this.props.cancelResolvingUris();
window.removeEventListener("scroll", this.scrollListener);
}
render() {
const { featuredUris, fetchingFeaturedUris } = this.props;
const hasContent =
typeof featuredUris === "object" && Object.keys(featuredUris).length,
failedToLoad = !fetchingFeaturedUris && !hasContent;
return (
{!hasContent &&
fetchingFeaturedUris &&
}
{hasContent &&
Object.keys(featuredUris).map(
category =>
featuredUris[category].length
?
: ""
)}
{failedToLoad &&
{__("Failed to load landing content.")}
}
);
}
}
export default DiscoverPage;