исправление при открытии торрента на странице

This commit is contained in:
Alexey Kasyanchuk
2017-01-19 15:54:24 +03:00
parent e6de177361
commit 671c836e24
2 changed files with 19 additions and 2 deletions

View File

@ -141,7 +141,7 @@ export default class TorrentPage extends Page {
value: value,
});
};
componentDidMount() {
getTorrentInfo() {
window.torrentSocket.emit('torrent', this.props.hash, {files: true}, window.customLoader((data) => {
if(data) {
this.torrent = data
@ -162,6 +162,17 @@ export default class TorrentPage extends Page {
searchingIndicator: false
});
}));
}
componentDidMount() {
this.getTorrentInfo();
this.filesUpdated = (hash) => {
if(this.props.hash != hash)
return;
this.getTorrentInfo();
}
window.torrentSocket.on('filesReady', this.filesUpdated);
this.trackerUpdate = (info) => {
if(this.props.hash != info.hash)
return;
@ -175,6 +186,8 @@ export default class TorrentPage extends Page {
window.torrentSocket.on('trackerTorrentUpdate', this.trackerUpdate);
}
componentWillUnmount() {
if(this.filesUpdated)
window.torrentSocket.off('filesReady', this.filesUpdated);
if(this.trackerUpdate)
window.torrentSocket.off('trackerTorrentUpdate', this.trackerUpdate);
}