Update <File /> when server/socket changes
This commit is contained in:
parent
d415c63734
commit
f0e70d7855
|
@ -37,13 +37,15 @@ function basename(path) {
|
||||||
|
|
||||||
class File extends Component {
|
class File extends Component {
|
||||||
shouldComponentUpdate(nextProps, _) {
|
shouldComponentUpdate(nextProps, _) {
|
||||||
return nextProps.file !== this.props.file;
|
return nextProps.file !== this.props.file
|
||||||
|
|| nextProps.server !== this.props.server
|
||||||
|
|| nextProps.socket !== this.props.socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { dispatch, file } = this.props;
|
const { dispatch, file, server, socket } = this.props;
|
||||||
const { uri } = store.getState().socket;
|
const { download_token } = server;
|
||||||
const { download_token } = store.getState().server;
|
const { uri } = socket;
|
||||||
return (
|
return (
|
||||||
<div className="file">
|
<div className="file">
|
||||||
<Progress
|
<Progress
|
||||||
|
@ -146,7 +148,15 @@ class Torrent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { dispatch, torrent, files, trackers, peers } = this.props;
|
const {
|
||||||
|
dispatch,
|
||||||
|
torrent,
|
||||||
|
files,
|
||||||
|
trackers,
|
||||||
|
peers,
|
||||||
|
server,
|
||||||
|
socket,
|
||||||
|
} = this.props;
|
||||||
const status = s => s[0].toUpperCase() + s.slice(1);
|
const status = s => s[0].toUpperCase() + s.slice(1);
|
||||||
|
|
||||||
if (!torrent || !files) {
|
if (!torrent || !files) {
|
||||||
|
@ -254,7 +264,12 @@ class Torrent extends Component {
|
||||||
{this.state.filesShown
|
{this.state.filesShown
|
||||||
? files.slice()
|
? files.slice()
|
||||||
.sort((a, b) => a.path.localeCompare(b.path))
|
.sort((a, b) => a.path.localeCompare(b.path))
|
||||||
.map(file => <File dispatch={dispatch} file={file}/>)
|
.map(file => <File
|
||||||
|
dispatch={dispatch}
|
||||||
|
file={file}
|
||||||
|
server={server}
|
||||||
|
socket={socket}
|
||||||
|
/>)
|
||||||
: null}
|
: null}
|
||||||
</div>
|
</div>
|
||||||
</CardBlock>
|
</CardBlock>
|
||||||
|
@ -390,6 +405,8 @@ class TorrentDetails extends Component {
|
||||||
trackers,
|
trackers,
|
||||||
peers,
|
peers,
|
||||||
selection,
|
selection,
|
||||||
|
server,
|
||||||
|
socket,
|
||||||
dispatch
|
dispatch
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const index_by_tid = (res) => {
|
const index_by_tid = (res) => {
|
||||||
|
@ -416,6 +433,8 @@ class TorrentDetails extends Component {
|
||||||
files={_files[id] || []}
|
files={_files[id] || []}
|
||||||
trackers={_trackers[id] || []}
|
trackers={_trackers[id] || []}
|
||||||
peers={_peers[id] || []}
|
peers={_peers[id] || []}
|
||||||
|
server={server}
|
||||||
|
socket={socket}
|
||||||
key={id}
|
key={id}
|
||||||
/>)}
|
/>)}
|
||||||
{selection.length > 3 ?
|
{selection.length > 3 ?
|
||||||
|
@ -437,5 +456,6 @@ export default connect(state => ({
|
||||||
trackers: state.trackers,
|
trackers: state.trackers,
|
||||||
peers: state.peers,
|
peers: state.peers,
|
||||||
selection: state.selection,
|
selection: state.selection,
|
||||||
server: state.server
|
server: state.server,
|
||||||
|
socket: state.socket,
|
||||||
}))(TorrentDetails);
|
}))(TorrentDetails);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user