lbry-desktop/ui/js/component/app/view.jsx
2017-11-14 22:50:21 -03:00

64 lines
1.3 KiB
JavaScript

import React from "react";
import Router from "component/router/index";
import Header from "component/header";
import Theme from "component/theme";
import ModalRouter from "modal/modalRouter";
import lbry from "lbry";
class App extends React.PureComponent {
componentWillMount() {
const {
alertError,
checkUpgradeAvailable,
initCheckUpgradeTimer,
fetchRewardedContent,
} = this.props;
document.addEventListener("unhandledError", event => {
alertError(event.detail);
});
if (!this.props.upgradeSkipped) {
checkUpgradeAvailable();
}
initCheckUpgradeTimer();
fetchRewardedContent();
this.scrollListener = () => this.props.recordScroll(window.scrollY);
window.addEventListener("scroll", this.scrollListener);
this.setTitleFromProps(this.props);
}
componentDidMount() {}
componentWillUnmount() {
window.removeEventListener("scroll", this.scrollListener);
}
componentWillReceiveProps(props) {
this.setTitleFromProps(props);
}
setTitleFromProps(props) {
window.document.title = props.pageTitle || "LBRY";
}
render() {
return (
<div id="window">
<Theme />
<Header />
<div id="main-content">
<Router />
</div>
<ModalRouter />
</div>
);
}
}
export default App;