Fix directly loading a torrent detail page

This commit is contained in:
Drew DeVault 2017-08-25 19:34:04 -04:00
parent 6983703672
commit d939ca662e
3 changed files with 34 additions and 22 deletions

View File

@ -12,27 +12,23 @@ import { filter_subscribe } from './actions/filter_subscribe';
import Nav from './ui/navigation';
import Main from './ui/main';
import Connection from './ui/connection';
const root = document.getElementById('root');
ReactDOM.render(<Connection />, root);
ws_init(() => {
store.dispatch(filter_subscribe());
store.dispatch(filter_subscribe('server'));
});
const render = App => ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<div>
<Nav />
<div className="container">
<App />
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<div>
<Nav />
<div className="container">
<Main />
</div>
</div>
</div>
</ConnectedRouter>
</Provider>,
document.getElementById('root'));
render(Main);
if (module.hot) {
module.hot.accept('./ui/main', () => render(Main));
}
</ConnectedRouter>
</Provider>, root);
});

9
src/ui/connection.js Normal file
View File

@ -0,0 +1,9 @@
import React, { Component } from 'react';
export default class Connection extends Component {
render() {
return (
<p>Connecting...</p>
);
}
}

View File

@ -13,9 +13,8 @@ import {
Progress
} from 'reactstrap';
import ws_send from '../socket';
import selectTorrent, { UNION } from '../actions/selection';
// TODO: use component lifecycle functions here to invoke
// torrent_state.updateSubscriptions
// TODO: fix navigating directly to torrent pages
function File({ file }) {
@ -152,6 +151,13 @@ class TorrentDetails extends Component {
};
}
componentDidMount() {
const { dispatch } = this.props;
const { ids } = this.props.match.params;
const _ids = ids.split(",");
_ids.forEach(id => dispatch(selectTorrent(id, UNION)));
}
renderHeader(selection) {
return (
<div>
@ -197,5 +203,6 @@ export default connect(state => ({
router: state.router,
torrents: state.torrents,
files: state.files,
selection: state.selection
selection: state.selection,
server: state.server
}))(TorrentDetails);