2017-04-07 07:15:22 +02:00
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
import lbry from 'lbry.js';
|
|
|
|
import Router from 'component/router'
|
2017-04-22 15:17:01 +02:00
|
|
|
import Header from 'component/header';
|
2017-04-07 07:15:22 +02:00
|
|
|
import {Modal, ExpandableModal} from 'component/modal.js';
|
|
|
|
import ErrorModal from 'component/errorModal'
|
|
|
|
import DownloadingModal from 'component/downloadingModal'
|
|
|
|
import UpgradeModal from 'component/upgradeModal'
|
|
|
|
import Link from 'component/link';
|
|
|
|
import {Line} from 'rc-progress';
|
|
|
|
|
|
|
|
const App = React.createClass({
|
|
|
|
// Temporary workaround since electron-dl throws errors when you try to get the filename
|
|
|
|
getViewingPageAndArgs: function(address) {
|
|
|
|
// For now, routes are in format ?page or ?page=args
|
|
|
|
let [isMatch, viewingPage, pageArgs] = address.match(/\??([^=]*)(?:=(.*))?/);
|
|
|
|
return {
|
|
|
|
viewingPage: viewingPage,
|
|
|
|
pageArgs: pageArgs === undefined ? null : pageArgs
|
|
|
|
};
|
|
|
|
},
|
|
|
|
componentWillMount: function() {
|
|
|
|
document.addEventListener('unhandledError', (event) => {
|
|
|
|
this.props.alertError(event.detail);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!this.props.upgradeSkipped) {
|
|
|
|
this.props.checkUpgradeAvailable()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
const {
|
|
|
|
currentPage,
|
|
|
|
openDrawer,
|
|
|
|
closeDrawer,
|
|
|
|
openModal,
|
|
|
|
closeModal,
|
|
|
|
modal,
|
|
|
|
drawerOpen,
|
|
|
|
headerLinks,
|
|
|
|
search,
|
|
|
|
searchTerm,
|
|
|
|
} = this.props
|
|
|
|
const searchQuery = (currentPage == 'discover' && searchTerm ? searchTerm : '')
|
|
|
|
|
2017-04-21 04:31:50 +02:00
|
|
|
return <div id="window" className={ drawerOpen ? 'drawer-open' : 'drawer-closed' }>
|
|
|
|
<Drawer onCloseDrawer={closeDrawer} viewingPage={currentPage} />
|
|
|
|
<div id="main-content" className={ headerLinks ? 'with-sub-nav' : 'no-sub-nav' }>
|
|
|
|
<Header onOpenDrawer={openDrawer} initialQuery={searchQuery} onSearch={search} links={headerLinks} />
|
|
|
|
<Router />
|
|
|
|
</div>
|
|
|
|
{modal == 'upgrade' && <UpgradeModal />}
|
|
|
|
{modal == 'downloading' && <DownloadingModal />}
|
|
|
|
{modal == 'error' && <ErrorModal />}
|
|
|
|
</div>
|
2017-04-07 07:15:22 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default App
|