Fix routing issues

This commit is contained in:
Drew DeVault 2017-09-08 11:06:49 +09:00
parent 98d15e9dec
commit 54030bb341
3 changed files with 11 additions and 8 deletions

View File

@ -16,8 +16,6 @@ import Nav from './ui/navigation';
import Main from './ui/main';
import Connection from './ui/connection';
const root = document.getElementById('root');
export function initialize(uri) {
ws_init(uri, () => {
store.dispatch(socket_connected());
@ -36,7 +34,7 @@ ReactDOM.render(
</div>
</div>
</ConnectedRouter>
</Provider>, root);
</Provider>, document.getElementById('root'));
navigator.registerProtocolHandler("magnet",
window.location.origin + "/add-torrent/%s",

View File

@ -1,4 +1,5 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import {
Card,
CardHeader,
@ -9,7 +10,7 @@ import {
} from 'reactstrap';
import { initialize } from '..';
export default class ConnectionOverlay extends Component {
class ConnectionOverlay extends Component {
constructor() {
super();
this.state = {
@ -23,6 +24,10 @@ export default class ConnectionOverlay extends Component {
}
render() {
const { socket } = this.props;
if (socket.connected) {
return null;
}
const { uri, autoconnect } = this.state;
return (
<div className="connection-overlay">
@ -58,3 +63,5 @@ export default class ConnectionOverlay extends Component {
);
}
}
export default connect(state => ({ socket: state.socket }))(ConnectionOverlay);

View File

@ -7,7 +7,7 @@ import TorrentDetails from './torrent_details';
import Server from './server';
import ConnectionOverlay from './connection';
class Main extends Component {
export default class Main extends Component {
render() {
return (
<div className="row">
@ -20,10 +20,8 @@ class Main extends Component {
<Route path="/torrents/:ids" component={TorrentDetails} />
<Route exact path="/" component={Server} />
</div>
{this.props.socket.connected || <ConnectionOverlay />}
<ConnectionOverlay />
</div>
);
}
}
export default connect(state => ({ socket: state.socket }))(Main);