React: clean up App component

This commit is contained in:
DC
2016-07-22 21:55:27 -07:00
parent 734b0731a1
commit 9df51aec49

View File

@@ -49,19 +49,18 @@ module.exports = class App extends React.Component {
var vdom = (
<div className={'app ' + cls.join(' ')}>
<Header state={state} />
{getErrorPopover(state)}
<div key='content' className='content'>{getView(state)}</div>
{getModal(state)}
{this.getErrorPopover()}
<div key='content' className='content'>{this.getView()}</div>
{this.getModal()}
</div>
)
return vdom
}
}
function getErrorPopover (state) {
getErrorPopover () {
var now = new Date().getTime()
var recentErrors = state.errors.filter((x) => now - x.time < 5000)
var recentErrors = this.state.errors.filter((x) => now - x.time < 5000)
var hasErrors = recentErrors.length > 0
var errorElems = recentErrors.map(function (error, i) {
@@ -76,7 +75,8 @@ function getErrorPopover (state) {
)
}
function getModal (state) {
getModal () {
var state = this.state
if (!state.modal) return
var ModalContents = Modals[state.modal.id]
return (
@@ -89,7 +89,9 @@ function getModal (state) {
)
}
function getView (state) {
getView () {
var state = this.state
var View = Views[state.location.url()]
return (<View state={state} />)
}
}