Show an error if there's no WebRTC support.

nb/hide-http
Alex Kern 11 years ago
parent 5eb9f91003
commit c5080872bb

@ -0,0 +1,9 @@
import alt from '../alt'
export default alt.createActions(class SupportActions {
constructor() {
this.generateActions(
'noSupport'
)
}
})

@ -2,6 +2,8 @@ import React from 'react'
import ReactRouter from 'react-router'
import routes from './routes'
import alt from './alt'
import webrtcSupport from 'webrtcsupport'
import SupportActions from './actions/SupportActions'
let bootstrap = document.documentElement.getAttribute('data-bootstrap')
alt.bootstrap(bootstrap)
@ -10,4 +12,6 @@ window.FilePizza = () => {
ReactRouter.run(routes, ReactRouter.HistoryLocation, function (Handler) {
React.render(<Handler data={bootstrap} />, document)
})
if (!webrtcSupport.support) SupportActions.noSupport()
}

@ -1,9 +1,27 @@
import ErrorPage from './ErrorPage'
import FrozenHead from 'react-frozenhead'
import React from 'react'
import SupportStore from '../stores/SupportStore'
import { RouteHandler } from 'react-router'
export default class App extends React.Component {
constructor() {
this.state = SupportStore.getState()
this._onChange = () => {
this.setState(SupportStore.getState())
}
}
componentDidMount() {
SupportStore.listen(this._onChange)
}
componentDidUnmount() {
SupportStore.unlisten(this._onChange)
}
render() {
return <html lang="en" data-bootstrap={this.props.data}>
<FrozenHead>
@ -23,7 +41,9 @@ export default class App extends React.Component {
</FrozenHead>
<body>
<RouteHandler />
{this.state.isSupported
? <RouteHandler />
: <ErrorPage />}
<script>FilePizza()</script>
</body>
</html>

@ -1,11 +1,20 @@
import SupportActions from '../actions/SupportActions'
import alt from '../alt'
export default alt.createStore(class ErrorStore {
constructor() {
this.bindActions(SupportActions)
this.status = 404
this.message = 'Not Found'
this.stack = null
}
onNoSupport() {
this.status = 400
this.message = 'No WebRTC Support'
this.stack = null
}
}, 'ErrorStore')

@ -0,0 +1,15 @@
import SupportActions from '../actions/SupportActions'
import alt from '../alt'
export default alt.createStore(class SupportStore {
constructor() {
this.bindActions(SupportActions)
this.isSupported = true
}
onNoSupport() {
this.isSupported = false
}
}, 'SupportStore')

@ -25,6 +25,8 @@
"browserify-middleware": "^5.0.2",
"classnames": "^1.2.0",
"express": "^4.12.0",
"filepizza-peer": "./node_modules/filepizza-peer",
"filepizza-socket": "./node_modules/filepizza-socket",
"morgan": "^1.5.2",
"nib": "^1.1.0",
"peer": "^0.2.8",
@ -33,8 +35,7 @@
"react-router": "^0.13.1",
"socket.io": "^1.3.5",
"stylus": "^0.50.0",
"filepizza-socket": "./node_modules/filepizza-socket",
"filepizza-peer": "./node_modules/filepizza-peer"
"webrtcsupport": "^2.1.2"
},
"engines": {
"node": "0.10.x"

Loading…
Cancel
Save