2017-06-06 23:19:12 +02:00
|
|
|
import React from "react";
|
2017-08-18 19:09:40 +02:00
|
|
|
import Router from "component/router/index";
|
2017-06-06 23:19:12 +02:00
|
|
|
import Header from "component/header";
|
2017-08-18 19:09:40 +02:00
|
|
|
import ModalRouter from "modal/modalRouter";
|
2017-06-06 23:19:12 +02:00
|
|
|
import lbry from "lbry";
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-06-08 06:42:19 +02:00
|
|
|
class App extends React.PureComponent {
|
2017-05-04 05:44:08 +02:00
|
|
|
componentWillMount() {
|
2017-07-25 09:07:54 +02:00
|
|
|
const {
|
|
|
|
alertError,
|
|
|
|
checkUpgradeAvailable,
|
|
|
|
updateBalance,
|
2017-07-30 00:56:08 +02:00
|
|
|
fetchRewardedContent,
|
2017-07-25 09:07:54 +02:00
|
|
|
} = this.props;
|
2017-07-16 18:29:46 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
document.addEventListener("unhandledError", event => {
|
2017-07-16 18:29:46 +02:00
|
|
|
alertError(event.detail);
|
2017-04-07 07:15:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!this.props.upgradeSkipped) {
|
2017-07-16 18:29:46 +02:00
|
|
|
checkUpgradeAvailable();
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
2017-05-15 18:34:33 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
lbry.balanceSubscribe(balance => {
|
2017-07-16 18:29:46 +02:00
|
|
|
updateBalance(balance);
|
2017-06-06 23:19:12 +02:00
|
|
|
});
|
2017-07-16 18:29:46 +02:00
|
|
|
|
2017-07-30 00:56:08 +02:00
|
|
|
fetchRewardedContent();
|
2017-07-25 09:07:54 +02:00
|
|
|
|
2017-07-19 10:35:03 +02:00
|
|
|
this.scrollListener = () => this.props.recordScroll(window.scrollY);
|
|
|
|
|
|
|
|
window.addEventListener("scroll", this.scrollListener);
|
2017-08-30 14:48:32 +02:00
|
|
|
|
|
|
|
this.setTitleFromProps(this.props);
|
2017-07-16 18:29:46 +02:00
|
|
|
}
|
|
|
|
|
2017-07-19 10:35:03 +02:00
|
|
|
componentWillUnmount() {
|
|
|
|
window.removeEventListener("scroll", this.scrollListener);
|
2017-05-04 05:44:08 +02:00
|
|
|
}
|
|
|
|
|
2017-08-30 14:48:32 +02:00
|
|
|
componentWillReceiveProps(props) {
|
|
|
|
this.setTitleFromProps(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTitleFromProps(props) {
|
|
|
|
window.document.title = props.pageTitle;
|
|
|
|
}
|
|
|
|
|
2017-05-04 05:44:08 +02:00
|
|
|
render() {
|
2017-06-06 23:19:12 +02:00
|
|
|
return (
|
|
|
|
<div id="window">
|
|
|
|
<Header />
|
|
|
|
<div id="main-content">
|
|
|
|
<Router />
|
|
|
|
</div>
|
2017-08-18 19:09:40 +02:00
|
|
|
<ModalRouter />
|
2017-04-21 04:31:50 +02:00
|
|
|
</div>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
2017-05-04 05:44:08 +02:00
|
|
|
}
|
2017-04-07 07:15:22 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default App;
|