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 ReactRouter from 'react-router'
import routes from './routes' import routes from './routes'
import alt from './alt' import alt from './alt'
import webrtcSupport from 'webrtcsupport'
import SupportActions from './actions/SupportActions'
let bootstrap = document.documentElement.getAttribute('data-bootstrap') let bootstrap = document.documentElement.getAttribute('data-bootstrap')
alt.bootstrap(bootstrap) alt.bootstrap(bootstrap)
@ -10,4 +12,6 @@ window.FilePizza = () => {
ReactRouter.run(routes, ReactRouter.HistoryLocation, function (Handler) { ReactRouter.run(routes, ReactRouter.HistoryLocation, function (Handler) {
React.render(<Handler data={bootstrap} />, document) 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 FrozenHead from 'react-frozenhead'
import React from 'react' import React from 'react'
import SupportStore from '../stores/SupportStore'
import { RouteHandler } from 'react-router' import { RouteHandler } from 'react-router'
export default class App extends React.Component { 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() { render() {
return <html lang="en" data-bootstrap={this.props.data}> return <html lang="en" data-bootstrap={this.props.data}>
<FrozenHead> <FrozenHead>
@ -23,7 +41,9 @@ export default class App extends React.Component {
</FrozenHead> </FrozenHead>
<body> <body>
<RouteHandler /> {this.state.isSupported
? <RouteHandler />
: <ErrorPage />}
<script>FilePizza()</script> <script>FilePizza()</script>
</body> </body>
</html> </html>

@ -1,11 +1,20 @@
import SupportActions from '../actions/SupportActions'
import alt from '../alt' import alt from '../alt'
export default alt.createStore(class ErrorStore { export default alt.createStore(class ErrorStore {
constructor() { constructor() {
this.bindActions(SupportActions)
this.status = 404 this.status = 404
this.message = 'Not Found' this.message = 'Not Found'
this.stack = null this.stack = null
} }
onNoSupport() {
this.status = 400
this.message = 'No WebRTC Support'
this.stack = null
}
}, 'ErrorStore') }, '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", "browserify-middleware": "^5.0.2",
"classnames": "^1.2.0", "classnames": "^1.2.0",
"express": "^4.12.0", "express": "^4.12.0",
"filepizza-peer": "./node_modules/filepizza-peer",
"filepizza-socket": "./node_modules/filepizza-socket",
"morgan": "^1.5.2", "morgan": "^1.5.2",
"nib": "^1.1.0", "nib": "^1.1.0",
"peer": "^0.2.8", "peer": "^0.2.8",
@ -33,8 +35,7 @@
"react-router": "^0.13.1", "react-router": "^0.13.1",
"socket.io": "^1.3.5", "socket.io": "^1.3.5",
"stylus": "^0.50.0", "stylus": "^0.50.0",
"filepizza-socket": "./node_modules/filepizza-socket", "webrtcsupport": "^2.1.2"
"filepizza-peer": "./node_modules/filepizza-peer"
}, },
"engines": { "engines": {
"node": "0.10.x" "node": "0.10.x"

Loading…
Cancel
Save