Fix routing issues
This commit is contained in:
parent
98d15e9dec
commit
54030bb341
|
@ -16,8 +16,6 @@ import Nav from './ui/navigation';
|
||||||
import Main from './ui/main';
|
import Main from './ui/main';
|
||||||
import Connection from './ui/connection';
|
import Connection from './ui/connection';
|
||||||
|
|
||||||
const root = document.getElementById('root');
|
|
||||||
|
|
||||||
export function initialize(uri) {
|
export function initialize(uri) {
|
||||||
ws_init(uri, () => {
|
ws_init(uri, () => {
|
||||||
store.dispatch(socket_connected());
|
store.dispatch(socket_connected());
|
||||||
|
@ -36,7 +34,7 @@ ReactDOM.render(
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ConnectedRouter>
|
</ConnectedRouter>
|
||||||
</Provider>, root);
|
</Provider>, document.getElementById('root'));
|
||||||
|
|
||||||
navigator.registerProtocolHandler("magnet",
|
navigator.registerProtocolHandler("magnet",
|
||||||
window.location.origin + "/add-torrent/%s",
|
window.location.origin + "/add-torrent/%s",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardHeader,
|
CardHeader,
|
||||||
|
@ -9,7 +10,7 @@ import {
|
||||||
} from 'reactstrap';
|
} from 'reactstrap';
|
||||||
import { initialize } from '..';
|
import { initialize } from '..';
|
||||||
|
|
||||||
export default class ConnectionOverlay extends Component {
|
class ConnectionOverlay extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = {
|
this.state = {
|
||||||
|
@ -23,6 +24,10 @@ export default class ConnectionOverlay extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { socket } = this.props;
|
||||||
|
if (socket.connected) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
const { uri, autoconnect } = this.state;
|
const { uri, autoconnect } = this.state;
|
||||||
return (
|
return (
|
||||||
<div className="connection-overlay">
|
<div className="connection-overlay">
|
||||||
|
@ -58,3 +63,5 @@ export default class ConnectionOverlay extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default connect(state => ({ socket: state.socket }))(ConnectionOverlay);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import TorrentDetails from './torrent_details';
|
||||||
import Server from './server';
|
import Server from './server';
|
||||||
import ConnectionOverlay from './connection';
|
import ConnectionOverlay from './connection';
|
||||||
|
|
||||||
class Main extends Component {
|
export default class Main extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
|
@ -20,10 +20,8 @@ class Main extends Component {
|
||||||
<Route path="/torrents/:ids" component={TorrentDetails} />
|
<Route path="/torrents/:ids" component={TorrentDetails} />
|
||||||
<Route exact path="/" component={Server} />
|
<Route exact path="/" component={Server} />
|
||||||
</div>
|
</div>
|
||||||
{this.props.socket.connected || <ConnectionOverlay />}
|
<ConnectionOverlay />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(state => ({ socket: state.socket }))(Main);
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user